Skip to content

Instantly share code, notes, and snippets.

@alexstorer
Created April 30, 2012 20:46
Show Gist options
  • Save alexstorer/2562538 to your computer and use it in GitHub Desktop.
Save alexstorer/2562538 to your computer and use it in GitHub Desktop.
copying files and renaming them
import fnmatch
import os
import shutil
import re
for file in os.listdir('.'):
flist = os.path.basename(file).split('.')
fname = flist[0]
fext = '.blah'
try:
newname = str(int(fname)+1289)
print fname + " is a tweet!"
shutil.move(fname+fext, newname+fext)
print "copied to "+newname+fext
except Exception:
print fname + " is not a tweet."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment