1 #!/usr/bin/env python
2 #coding=utf-8
3
4 import os
5 import sys
6
7 pubid0=0000000
8 pubid1=1111111
9 path=1111111
10
11 def get_filenames(fdir):
12
13 return os.listdir(fdir)
14
15 def rename_file(filename,pubid0,pubid1):
16
17 os.rename(filename,filename.replace(pubid0,pubid1))
18
19
20 if __name__ == '__main__':
21
22 path = sys.argv[1]
23 pubid0 = sys.argv[2]
24 pubid1 = sys.argv[3]
25 print '\t path :',path,'\t pubid0:',pubid0,'\t pubid1:',pubid1
26 print '\t\t***************************************\n'
27
28 filesname = get_filenames(path)
29 for i in filesname:
30 # print i ,os.path.join(path,i)
31 nPos =str(i).find(pubid0)
32 if nPos > 0:
33 rename_file(os.path.join(path,i),pubid0,pubid1)
34 print os.path.join(path,i)
2 #coding=utf-8
3
4 import os
5 import sys
6
7 pubid0=0000000
8 pubid1=1111111
9 path=1111111
10
11 def get_filenames(fdir):
12
13 return os.listdir(fdir)
14
15 def rename_file(filename,pubid0,pubid1):
16
17 os.rename(filename,filename.replace(pubid0,pubid1))
18
19
20 if __name__ == '__main__':
21
22 path = sys.argv[1]
23 pubid0 = sys.argv[2]
24 pubid1 = sys.argv[3]
25 print '\t path :',path,'\t pubid0:',pubid0,'\t pubid1:',pubid1
26 print '\t\t***************************************\n'
27
28 filesname = get_filenames(path)
29 for i in filesname:
30 # print i ,os.path.join(path,i)
31 nPos =str(i).find(pubid0)
32 if nPos > 0:
33 rename_file(os.path.join(path,i),pubid0,pubid1)
34 print os.path.join(path,i)