Skip to content

Instantly share code, notes, and snippets.

@Edwardtonnn
Created July 13, 2023 17:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Edwardtonnn/7b58d25a1989c11678fc45d381efaab4 to your computer and use it in GitHub Desktop.
Save Edwardtonnn/7b58d25a1989c11678fc45d381efaab4 to your computer and use it in GitHub Desktop.
Python to rename files
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