ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/FileExtReplace.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
File size: 564 byte(s)
Log Message:
Initial Import

File Contents

# Content
1 ## FileExtReplace.py
2 ## Just a simple path walking program that will replace the ext with a different ext.
3 ## EBorges
4 ## 9.16.05
5
6 import os
7
8 def ReplaceExt(args, dirName, filesInDir):
9 for file in filesInDir:
10 newFile = os.path.splitext(file)
11 if newFile[1] == args[0]:
12 os.rename(dirName + '\\' + file, dirName + '\\' + newFile[0] + args[1])
13
14
15 if __name__ == '__main__':
16 startDir = r'\\mwcase01\Images\WorldBank\images\WSB3'
17 replacement = ['.001','.pdf']
18 os.path.walk(startDir, ReplaceExt, replacement)