Last active
September 17, 2022 08:24
-
-
Save hipertracker/0fb6e6199673bf1d1c59cc1fa5308d45 to your computer and use it in GitHub Desktop.
This file contains 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 | |
def rename_folders(path, dirs, src, dst): | |
for name in os.listdir(path): | |
if re.match(dirs, name): | |
name2 = re.sub(src, dst, name) | |
filepath1 = path + os.sep + name | |
filepath2 = path + os.sep + name2 | |
os.rename(filepath1, filepath2) | |
if __name__ == '__main__': | |
rename_folders( | |
path='/Volumes/Bydle4TB/FILMY', | |
dirs=r'^\d{4} - ', | |
src=r'^(\d{4}) - (.+)', | |
dst=r'\2 (\1)' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment