Skip to content

Instantly share code, notes, and snippets.

@calderonsteven
Created March 20, 2015 20:12
Show Gist options
  • Select an option

  • Save calderonsteven/78f76b5ea5c8c6d5b3e8 to your computer and use it in GitHub Desktop.

Select an option

Save calderonsteven/78f76b5ea5c8c6d5b3e8 to your computer and use it in GitHub Desktop.
rename files in a folder
import os
mypath = 'C:\Users\Edward Calderon\Downloads\RDX exterior 360\RDX exterior 360\SilverMoon\jpg'
baseName = 'Silver_Moon_'
counter = 1
for f in os.listdir(mypath):
newFilename = '{baseName}{counter:04d}.jpg'.format(baseName=baseName, counter=counter)
os.rename(os.join(mypath,f), os.join(mypath, newFilename))
counter += 1
print 'Ok for {0}'.format(newFilename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment