-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprintEmptyDirectories.py
58 lines (39 loc) · 1.09 KB
/
printEmptyDirectories.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python
#
import sys,string,time,os,commands
from myUtils import *
def usage():
""" Usage: pyRemove listOfFiles <directory>
Removes files from list. If no directory is given, files are assumed to reside in current directory
"""
pass
def getFileList(infile):
import string
filelist=[]
ifile=OpenFile(infile,"r")
x = ifile.readline()
while x != "":
xx=string.rstrip(x)
z=string.split(xx)
if len(z) != 2:
print z
else:
fsize=int(z[0])
if fsize<10:
filelist.append(z[1])
x = ifile.readline()
CloseFile(ifile)
return filelist
if __name__ == '__main__':
narg=len(sys.argv)
if narg < 2:
print usage.__doc__
sys.exit(1)
infile=sys.argv[1]
files=getFileList(infile)
print len(files)
for ifile in files:
filename=os.path.join("/pnfs/cms/WAX/11/store/user/lpchbb/apana",ifile)
if not os.path.exists(filename):
print filename
os.rmdir(filename)