Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
685 B
3
Indexable
Never
import os

def add_suffix_to_files(folder_path, suffix):
    for foldername, subfolders, filenames in os.walk(folder_path):
        for filename in filenames:
            base_name, *extensions = filename.split(".")
            new_filename = base_name + suffix + "." + ".".join(extensions)
            old_path = os.path.join(foldername, filename)
            new_path = os.path.join(foldername, new_filename)
            os.rename(old_path, new_path)
            print(f'Renamed: {old_path} -> {new_path}')

# Example usage:
folder_path = r'C:\Users\bentc\Documents\Project Fulda\Workbench\Project_Fulda\Prefabs'
suffix = '_fd'
add_suffix_to_files(folder_path, suffix)
Leave a Comment