Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

As we move on with our content-based websites, lots of images get dumped in our images folder, but we rarely come across self-committed monkyes that delete their files once they do not need it, which means, we end up with a huge list of images in one folder, and it is very tricky to clean it up. My question is (and i dont know if this is the right website to ask it), is there a tool that allows me to find out if an image has been requested by web in the last (n) months?

my other general question is, how do you do it? how do you take control of your images folders? what policy do you enforce on developers to clean up? what measures do you take in order to decide what goes and what stays if you end up with an out-of-control situation?

my suggestion was to rename the images folder, create a new one, copy the basic ones and wait for someone to complain about a broken image! :) i find this to be the most efficient.

share|improve this question
add comment

6 Answers

Does your web content management tool allow you to report on or query which images are linked in the site content? Or can you run a string search for image file extensions in the content pages? If so, that report combined with a list of the images from web server logs in the last 12 months (or longer depending on your site) should be enough to identify needed images. This assumes image file requests appear in your server logs. If you have a scripting environment available on the server then you could script the removal of images not included in those lists. You could also create a second folder and move all the needed images there, and do the rename you outlined.

Of course, take a backup or two first, and test it works!

Your other approach, depending on the size of the site, would be to add more storage. This might be cheaper and quicker than spending your time sorting through a bunch of image files. This also prevents any later issues where images were linked directly from other sites or associated with content that is important but infrequently used.

share|improve this answer
    
no i wish i had a content management tool, its a remote server with 100s if sub sites, and 100s of teams working on it, but we were asked to reduce the size of the images folder, frankly i dont care about the other 100 teams that worked on this before so i would go to extremese in deleting them, but i want a reasonable rule to measure against, u know what i mean? so all ur methods are great but non of them work in my situation :) –  Ayyash Apr 13 '10 at 0:21
    
If you have no access (or desire) to parse server logs, then there's not likely going to be a reliable way of doing this. –  Mark Henderson Apr 13 '10 at 0:36
    
but server logs give me what information? when the images were last access by web? i can obtain them if they are helpful –  Ayyash Apr 13 '10 at 0:43
    
Depends on the logging level, but yes. The logs may well state that such-and-such user downloaded such-and-such image on such-and-such date. So you just search through the logs for any occurance of candidatefordeletion.jpg and if it doesn't show up, you're more confident it can be deleted. Alternatively, search through the websites actual HTML content to see if the image is linked anywhere. Assuming it's static. –  Chris Thorpe Apr 13 '10 at 3:06
    
im trying to hunt down server logs but i dont know what to ask for exactly, is there a technical term to define these logs? when i asked our admins they didnt understand what i was talking about! –  Ayyash May 10 '10 at 21:31
show 1 more comment

It may not be elegant but what the systemadmin did when the folder was getting rediculously big was take a backup of the folder (yup, 12gb of publicity material) was sort all material by date last accessed, then date created, and delete any stuff older than 1 year. It's not quite what you want but it would work-ish.

share|improve this answer
    
i tried sorting by last accessed date, it is not indicative of when the image was last consumed by web :( –  Ayyash Apr 13 '10 at 0:41
add comment

Two simple ways to do what you want.

  1. Parse the web server logs (e.g. using Perl) and build a list of files that have been accessed, then remove all the others. Not my preferred way of doing things.
  2. Parse the links on your web site (if the site is built in a way that makes this practical) and remove any files not linked to. Much preferred where this is feasible, as it takes into account rarely accessed content.
share|improve this answer
add comment

After hunting down the log files, turned out the main server IIS does not log any data due to performance issue, and some "politics"! ended up creating my own "watch" log, where i read all incoming requests, check if it is inside the images folder, and open a text file, add the image url, and the urlReferrer, after a months time, i was able to make an educated guess of which folders should go

thanks everyone for your input on this

share|improve this answer
add comment

Try FlexTk file management toolkit, which is capable of performing rule-based file management operations.

Check this tutorial for more details:

http://www.flexense.com/resources/organize_tutorial.html

share|improve this answer
add comment

why not run a script on fixed intervals to check for the files last accessed status and delete them based on aging parameter?

you can evaluate the access time in unix like systems using find -atime <arg> where arg is number of days with +/- to mean more or less respectively

so you can feed the output of the find -atime +90 "*.jpg" for example to search for jpg images last accessed more than 90 days back to a for loop, where you feed it to a $f variable for example and loop on them with rm command

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.