Created
March 9, 2022 15:37
-
-
Save stilobique/64507d8f65518d8659eaf34f7c7c504c to your computer and use it in GitHub Desktop.
Python to rename all files in a dedicated folder
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 | |
def rename_with_prefix(path_rename, prefix: str = 'T_QUAJ_HDRI_'): | |
for root, folders, files in os.walk(path_rename): | |
for file in files: | |
print(f'Rename {os.path.join(root, file)}') | |
os.rename(os.path.join(root, file), os.path.join(root, f'{prefix}{file}')) | |
if __name__ == "__main__": | |
path = input('Give your absolute path where you want rename a file :') | |
rename_with_prefix(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment