Rename File

import os
 
count_cpk = 1
count_kwg = 1
count_lrg = 1
count_ntk = 1
count_prg = 1
 
for filename in os.listdir("."):
	#print filename
	if "CPK" in filename:
		os.rename(filename, "CPK" + "{0:04d}".format(count_cpk) + ".jpg")
		count_cpk += 1
		#print "CPK" + str(count_cpk)
	if "KWG" in filename:
		os.rename(filename, "KWG" + "{0:04d}".format(count_kwg) + ".jpg")
		count_kwg += 1
		#print "KWG" + str(count_kwg)
	if "LRG" in filename:
		os.rename(filename, "LRG" + "{0:04d}".format(count_lrg) + ".jpg")
		count_lrg += 1
		#print "LRG" + str(count_lrg)
	if "NTK" in filename:
		os.rename(filename, "NTK" + "{0:04d}".format(count_ntk) + ".jpg")
		count_ntk += 1
		#print "NTK" + str(count_ntk)
	if "PRG" in filename:
		os.rename(filename, "PRG" + "{0:04d}".format(count_prg) + ".jpg")
		count_prg += 1
		#print "PRG" + str(count_prg)

Leave a Reply

Your email address will not be published. Required fields are marked *

Afiseaza emoticoanele Locco.Ro