Skip to content

Instantly share code, notes, and snippets.

@choowilson
Created October 30, 2019 11:30
Show Gist options
  • Save choowilson/c0a9cadf5c92ea1c64911a26cd1281b5 to your computer and use it in GitHub Desktop.
Save choowilson/c0a9cadf5c92ea1c64911a26cd1281b5 to your computer and use it in GitHub Desktop.
simple python script to rename all files in a directory
import os
source_dir="red2"
list = os.listdir(source_dir)
print(list)
for index,filename in enumerate(list):
src = os.path.join(source_dir,filename)
dst = os.path.join(source_dir,"red"+str(index)+".jpg")
os.rename(src,dst)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment