Skip to content

Instantly share code, notes, and snippets.

@ghukill
Created October 27, 2016 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghukill/89b9462790a53068b1ef93303265e602 to your computer and use it in GitHub Desktop.
Save ghukill/89b9462790a53068b1ef93303265e602 to your computer and use it in GitHub Desktop.
Handy little script for bumping filenames from our book scanner
import os
files = os.listdir('.')
files.sort(reverse=True)
for f in files:
fnum = f.split('.')[0].lstrip("0")
if fnum == '':
fnum = "0"
newfnum = str(int(fnum) + 1)
newf = "%s.%s" % ( newfnum.zfill(3),f.split(".")[-1] )
print "converting %s --> %s" % (f,newf)
os.rename(f,newf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment