| 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) |