Last active
March 29, 2016 18:59
-
-
Save mattjared/3696538b0995e3fee04e480035b89708 to your computer and use it in GitHub Desktop.
Rename Files in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob, os | |
def rename(dir, pattern, titlePattern): | |
for pathAndFileName in glob.iglob(pattern): | |
print pathAndFileName | |
os.rename(pathAndFileName, titlePattern % pathAndFileName) | |
rename(r'~/Path/to/directory', r'*.file-type', r'newName-%s') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment