def cleanup (self, preserved):
global counter
counter+=1
- if self.options.dry_run:
- print "Would cleanup %s"%(self.path())
- print " (keeping %s)"%preserved.path()
+ if self.options.destination:
+ dst = os.path.abspath(self.options.destination) + '/' + os.path.basename(self.path())
+ if self.options.verbose:
+ print "moving %s\n\tto %s"%(self.path(), dst)
+ if not self.options.dry_run:
+ os.rename (self.path(), dst)
else:
- if self.options.verbose: print "unlink",self.path()
- os.unlink (self.path())
+ if self.options.dry_run:
+ print "Would cleanup %s"%(self.path())
+ print " (keeping %s)"%preserved.path()
+ else:
+ if self.options.verbose: print "unlink",self.path()
+ os.unlink (self.path())
# all files in a given timeslot (either month or week)
class Group:
help="run in extra verbose mode")
parser.add_option ("-n","--dry-run",dest='dry_run',action='store_true',default=False,
help="dry run")
+ parser.add_option ("-m","--move-to",dest='destination',action='store',type='string',default=False,
+ help="move to <destination> instead of removing the file")
parser.add_option ("-o","--offset",dest='offset',action='store',type='int',default=0,
help="pretend we run <offset> days in the future")
(options, args) = parser.parse_args()
print "Offset not understood %s - expect an int. number of days"%options.offset
sys.exit(1)
+ if options.destination and not os.path.isdir(options.destination):
+ print "Destination should be a directory"
+ sys.exit(1)
+
if len(args) ==0:
parser.print_help()
sys.exit(1)