Created
January 4, 2018 22:24
-
-
Save santiago-salas-v/aee6fd3637a2f555e6d067d349652974 to your computer and use it in GitHub Desktop.
recursively walk and replace file names containing str '[replaceme]'
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 | |
replace_str = '[replaceme]' | |
for root, dirs, files in os.walk('.'): | |
for file in files: | |
if replace_str in file: | |
new_file = file.replace(replace_str,'') | |
os.rename( | |
os.path.join(root,file), | |
os.path.join(root,new_file) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment