Created
July 13, 2023 17:54
-
-
Save Edwardtonnn/7b58d25a1989c11678fc45d381efaab4 to your computer and use it in GitHub Desktop.
Python to rename files
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 | |
folder_path = os.getcwd() | |
for filename in os.listdir(folder_path): | |
if filename.endswith(".png.jpg"): | |
new_filename = filename.replace(".png", "") | |
os.rename(os.path.join(folder_path, filename), os.path.join(folder_path, new_filename)) | |
print("Renamed '{}' to '{}'".format(filename, new_filename)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment