22
33import os
44import shutil
5- import tempfile
6- import re
5+ import time
76from sys import argv
87
98MIN_FILE_SIZE = 120 * 1024 * 1024
@@ -21,37 +20,35 @@ def countLargeFiles(dir):
2120 count += countLargeFiles (path )
2221 return count
2322
24- def cleanup (root , recycleBin ):
23+ def cleanup (root ):
2524 files = os .listdir (root )
2625 for file in files :
2726 path = os .path .join (root , file )
2827 if os .path .isdir (path ):
2928 count = countLargeFiles (path )
3029 if count == 0 :
31- print ("Removing %s" % path )
32- dest = tempfile .mkdtemp ("" , file , recycleBin )
33- shutil .move (path , dest )
30+ sinceUpdated = (time .time () - os .path .getmtime (path )) / 60 / 60 / 24
31+ if sinceUpdated > 14 :
32+ print ("Removing %s" % path )
33+ shutil .rmtree (path )
34+ # dest = tempfile.mkdtemp("", file, recycleBin)
35+ # shutil.move(path, dest)
3436
3537
3638if __name__ == '__main__' :
37- recycleBin = argv [- 1 ]
38- if os .path .exists (recycleBin ):
39- shutil .rmtree (recycleBin )
40- os .makedirs (recycleBin )
41-
42- for root in argv [1 :- 1 ]:
43- files1 = os .listdir (root )
44- for file1 in files1 :
45- path1 = os .path .join (root , file1 )
46- if os .path .isdir (path1 ):
47- files2 = os .listdir (path1 )
48- for file2 in files2 :
49- if re .match ("S\\ d+" , file2 ):
50- path2 = os .path .join (path1 , file2 )
51- cleanup (path2 , recycleBin )
52-
53- for root in argv [1 :- 1 ]:
54- cleanup (root , recycleBin )
39+ # for root in argv[1:]:
40+ # files1 = os.listdir(root)
41+ # for file1 in files1:
42+ # path1 = os.path.join(root, file1)
43+ # if os.path.isdir(path1):
44+ # files2 = os.listdir(path1)
45+ # for file2 in files2:
46+ # if re.match("S\\d+", file2):
47+ # path2 = os.path.join(path1, file2)
48+ # cleanup(path2)
49+
50+ for root in argv [1 :]:
51+ cleanup (root )
5552
5653
5754
0 commit comments