Skip to content

Instantly share code, notes, and snippets.

@karthick965938
Last active May 9, 2020 13:10
Show Gist options
  • Save karthick965938/c1db0cf346947ba86e33beca8985018d to your computer and use it in GitHub Desktop.
Save karthick965938/c1db0cf346947ba86e33beca8985018d to your computer and use it in GitHub Desktop.
python file name inside the folder
import os
os.getcwd()
collection = "images/cat"
for i, filename in enumerate(os.listdir(collection)):
print(filename)
os.rename(collection + "/" + filename, collection + "/cat" + str(i) + ".jpg")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment