Created
April 27, 2014 02:00
-
-
Save jackeylu/11335940 to your computer and use it in GitHub Desktop.
naming a batch of files with sequence index
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
# coding: utf-8 | |
import glob | |
files = glob.glob("*") # get the file list of current directory | |
out = open("m.bat","w") # generate bat file | |
i = 1 # where the index start from | |
for f in files: | |
newname = "%03.d%s" %(i,f) # output new file name like 001filename, 002filename | |
out.writelines("move %s %s\n"%(f, newname)) | |
i = i +1 | |
out.close() | |
# all right now, run the m.bat in shell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment