Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: cp1252 -*-
- import os
- #file extension that will be added to the end
- desiredExtension = ".jpg"
- #make list of contents of current directory
- dirList = os.listdir('')
- #bring up each filename at a time to rename
- for thisFile in dirList:
- if thisFile.endswith(".py") == False and thisFile.endswith(desiredExtension) == False:
- (baseName, oldExtension) = os.path.splitext(thisFile)
- os.rename(thisFile, baseName+oldExtension+desiredExtension)
- print(thisFile+" renamed to: "+baseName+oldExtension+desiredExtension)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement