Created
October 27, 2016 18:16
-
-
Save ghukill/89b9462790a53068b1ef93303265e602 to your computer and use it in GitHub Desktop.
Handy little script for bumping filenames from our book scanner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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