Batch Rename Images with python: Copy JPG and PNG Files with a Prefix
I recently needed to rename a large number of images. Doing it one file at a time was tedious, so I wrote a small batch-processing script.
What the Script Does
The script finds .jpg and .png files in a source directory, adds a user-supplied prefix to each filename, and copies the renamed files to a destination directory. The originals remain unchanged.
Environment
python 3 or later.
Code
| |
On systems with case-sensitive suffix checks, extend the condition or use file.lower().endswith(('.jpg', '.png')) if files may use uppercase extensions.