Created
March 29, 2016 09:50
-
-
Save meeuw/16cd012699e8ad7e5c21 to your computer and use it in GitHub Desktop.
rename png's numbered with an underscore
This file contains hidden or 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 fileinput | |
import os.path | |
d = {} | |
for line in fileinput.input(): | |
s = line[:-1].split('\t') | |
d[s[0]] = s[1] | |
for key, value in d.items(): | |
i = 0 | |
while 1: | |
i += 1 | |
if i == 1: | |
filename = '%s.png' % key | |
newfilename = 'dmchanged_%s.png' % value | |
else: | |
filename = '%s_%i.png' % (key, i) | |
newfilename = 'dmchanged_%s_%i.png' % (value, i) | |
if not os.path.exists(filename): break | |
os.rename(filename, newfilename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment