Skip to content

Instantly share code, notes, and snippets.

@stilobique
Created March 9, 2022 15:37
Show Gist options
  • Save stilobique/64507d8f65518d8659eaf34f7c7c504c to your computer and use it in GitHub Desktop.
Save stilobique/64507d8f65518d8659eaf34f7c7c504c to your computer and use it in GitHub Desktop.
Python to rename all files in a dedicated folder
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