If you are using python you can use the glob and os modules. Here is a small script that I used that would look for an extension and change the extension to another extension. The script is just quick and dirty, but it may help you along.
Code:
import glob
import os
look_for_ext = raw_input("What is the extension to look for? (ex: *.jpg): ")
print "Looking for: ", look_for_ext
change_to_ext = raw_input("What is the extension to change it to? (ex: .png): ")
print "Changing to: ", change_to_ext
files = glob.glob(look_for_ext)
print "The files: ", files
go_ahead = raw_input("Go ahead? Type Y or N ")
print go_ahead
if go_ahead == "Y" or go_ahead == "y":
go_ahead = True
else:
go_ahead = False
#print go_ahead
if files != None:
if go_ahead == True:
print "True"
for each in files:
#print os.path.splitext(each)
(basename,ext) = os.path.splitext(each)
#print "Basename: ", basename
#print "Extension: ", ext
os.rename(each,basename+change_to_ext)
print "Renamed ", each, " to ", basename+change_to_ext
Bookmarks