import glob import os dir = '/home3/division/' files = glob.glob('%s/*' % dir) files.sort() for file in files[:-7]:
Is this a little dangerous? It looks like it will delete the last seven files in the dir - every time you run it!
Surely you want to put a date restriction on it so it won't delete newer files than you should?
Or maybe delete the oldest files but KEEP at least x of them.
I didn't read any earlier posts on this so maybe I'm barking up the wrong tree :)
This way, i think, i still can manage some of my backup files base on how many times the system backup, regardless when they're backup. My backup script not always run every day, one script runs just weekdays and another is twice a week. But in another case, I will use one of op's sugestions. regards, -- Arie Reynaldi Zanahar reymanx at gmail.com http://www.reynaldi.or.id