Created
June 7, 2017 09:50
-
-
Save jihyeonRyu/f9faf11871df2cf3acdcd93416c38ce8 to your computer and use it in GitHub Desktop.
rename the files
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
#!/usr/bin/python | |
import sys | |
import os | |
import shutil | |
from wand.image import Image | |
name = raw_input("New Name: ") | |
files = os.listdir(sys.argv[1]) | |
p = str(sys.argv[1]) | |
p = '/mnt/c/Users/ryuji/' + p + '/' | |
newp = p + name + '/' | |
os.mkdir(newp) | |
for i in range(len(files)): | |
fn = os.path.splitext(files[i]) | |
oldname = "%s%s%s" %(p, fn[0], fn[1]) | |
if "png" not in files[i]: | |
with Image(filename = p + files[i]) as image: | |
with image.convert("png") as convert: | |
convert.save(filename = p + fn[0] + "." + "png") | |
print "%s %s" %(fn[0], fn[1]) | |
newname = "%s%s%d.png" %(newp, name, i) | |
os.rename(oldname, newname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment