On Wed, Dec 22, 2010 at 11:18:40AM +0000, Mark Rogers wrote:
Is there a simple way to locate directories which only contains files older than a certain date and then remove the directories?
I can find old files easily enough, but if a directory has more than one file in it and one of the files is new, then I need to not touch the entire directory. It's only where all the files are old that I want it removed.
I think that's just about the level of 'difficultness' where I move from a bash script to python. IMHO Python lends itself very well to jobs like this. Python has a ready made function that 'walks' a directory tree like find does so all you need is a bit of logic to check if all the files in a directory are older than x and, if so, delete the directory.