Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Cleaning out the assets folder


Go to End
Reply


9 Posts   1134 Views

Avatar
Futureweb

Community Member, 233 Posts

11 December 2012 at 12:50pm

Hi,

I manage a few sites which are quite old, and where the assets folder contains over a gig of files which the client has been uploading into for years.

What i'm looking for is a module which lists all the files in the assets area, the file sizes, date uploaded, and how many times this file is used (eg, linked to either through has_one with a database, or linked into the html content of a page)

Then, either through script, or manually, the client would be able to delete their old files, and make the whole site a lot easier to manage.

Does anyone know if such a module exists?

Cheers

Avatar
Stef87

Community Member, 66 Posts

13 December 2012 at 1:50am

Hi

I haven't used this so I'm not sure if it does exactly what you want but here's a link anyway.

http://www.silverstripe.org/versioned-files-module/

Avatar
zenmonkey

Community Member, 532 Posts

14 December 2012 at 4:01am

I know SS3 does a much better job at tracking backlinks for files. I'm getting to this point with one of my clients SS2.x and dreading tackling it because I need to move it to a new host.

Avatar
Bigfork

Community Member, 22 Posts

14 December 2012 at 5:10am

SS3 seems to track images used in UploadFields but in HTMLEditorFields SS3 images and files are inserted as HTML with their URLs. It would be good if these were replaced with database IDs like how page links are done so it had a means of saying if / where / how often an image was used.

Avatar
zenmonkey

Community Member, 532 Posts

14 December 2012 at 5:32am

I'm just going off the top of my head so it's totally hacky, but I guess you could do a custom controller that loops through all file objects, then searches all the content fields (on Page + any custom DataObjects with HTML Content) for a version of the $Name field stripped of the extension. Uou could then check and relations as well. If the search returns no results it deletes the object. Not an efficient function but theoretically you'd only run it occasionally, and probably manually.

Like I said hacky, but hey I'm writing this while eating lunch :)

Avatar
Futureweb

Community Member, 233 Posts

14 December 2012 at 9:37am

Hi
thanks for the comments, unfortunately these sites are both in ss 2.3 or 2.4 - they're old and big, making upgrade, or managing the files a bit tricky.

zenmonkey, that's the kind idea I was thinking of, was just wondering someone else had already done the coding!

Avatar
zenmonkey

Community Member, 532 Posts

14 December 2012 at 9:51am

Well I was thinking of throwing something like that together this weekend. I'm moving a clients site from shared hosting (DreamHost) to a Media Temple VS, if I don't have to move the chuff it'll be much better. If I'm successul I'll post my code. My worry is that on shared hosting that many calls may choke hard limits on memory.

Avatar
Futureweb

Community Member, 233 Posts

14 December 2012 at 9:58am

zenmonkey - would be keen to here how you get on!

Could probably just start by getting the first 100 files or so, and finding any links batch by batch, or else like you say it could overload stuff if there are thousands of files searching through thousands of pages...

Go to Top