19-05-2010

Python Python rename files batch

Simple example of renaming some files with Python script

#!c:/Python26/python.exe -u
import os
 
path = "testflvs/tfcache"
 
newnames = ["00461211",
"00461210",
"00461209",
"00461208",
"00461207",
"00461206",  
"00461205",  
"00461204",  
"00461203",  
"00461202",  
"00461201",  
"00461200"]  
 
i = 0
print (path)
tree = os.walk(path)
for (path, dirs, file) in tree:
	for filename in file:
		print (filename)
		print (newnames[i])
	 	os.rename(os.path.join(path, filename), os.path.join(path,  newnames[i]+".flv"))
		i+=1
 

Comments:

Your comment:

»

 

[x]