Recursive rename in python script
#!/usr/bin/env python
import fnmatch
import os
root = os.getcwd()
pattern = "*.JPG"
for root, dirs, files in os.walk(root):
for filename in fnmatch.filter(files, pattern):
#print (os.path.join(root, filename))
full_src = os.path.join(root, filename)
full_dst = full_src.replace('.JPG','.jpg')
os.rename(full_src, full_dst)
print "Renaming {0} to {1}".format(full_src, full_dst)
Comments
Post a Comment