Created
November 30, 2018 22:41
-
-
Save mhweber/fdcb482c65c33d2e44dda2caad413c90 to your computer and use it in GitHub Desktop.
Rename multiple files in a directory using list comprehension
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 os | |
| path = 'some/path' | |
| [os.rename(f, f.replace('some_text','new_text')) for f in os.listdir(path) if f.count('text_to_look_for')] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment