清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#!/usr/bin/python import os, sys,datetime,time from stat import * import shutil path='E:\\svnbak\\' filelist=[] filelist=os.listdir(path) def delete_file_folder(src): '''delete files and folders''' if os.path.isfile(src): try: os.remove(src) except: pass elif os.path.isdir(src): for item in os.listdir(src): itemsrc=os.path.join(src,item) delete_file_folder(itemsrc) try: os.rmdir(src) except: pass for file in filelist: if os.path.isdir(file): continue else: t1 = time.gmtime(os.stat(path+file)[ST_MTIME]) t11 = time.strftime('%Y-%m-%d',t1) print t11 year,month,day=t11.split('-') t111= datetime.datetime(int(year),int(month),int(day)) t2 = time.gmtime() t22 = time.strftime('%Y-%m-%d',t2) year,month,day=t22.split('-') t222= datetime.datetime(int(year),int(month),int(day)) days = (t222-t111).days print str(t22) if days>=7 : try: print "I will delete file "+path+file os.delete_file_folder(os.opath.abspath(os.path.join(path,file))) print "I will delete file "+path+file except Exception, e: print e import subprocess str_cmd='svnadmin hotcopy D:\\Repositories\\hannel E:\\svnbak\\data'+t22+' --clean-logs' p = subprocess.call(str_cmd)