Wednesday, September 4, 2013

A simple Python script for renaming filenames in the current folder

Suppose you have a set of image files which contains a certain text that you want to remove from the image filenames, below is the Python script to do it:
import os

for filename in os.listdir("."):
 if " (Small)" not in filename: continue
 os.rename(filename, filename.replace(" (Small)", ""))

No comments:

Post a Comment