Batch Rename File Extensions on Windows3rd November 2007
"Necessity is the mother of invention" turned true to me this weekend as I wrote this script. Consider this. You go on a weekend outing with your friends and end up taking hundreds of snaps using your favourite digital camera. You come home and download all the pictures to your laptop. Everything is fine about the pictures and all your friends are happy with the image quality. But, you being a perfectionism and systematism freak, somehow don't like to have those ".JPG" extensions to your files. You wish you could change the extensions of all those files to ".jpeg" in one shot.
Here comes renamex.bat to your rescue! Just download the script and set the location of the directory where you saved the script, in the %PATH% Environment Variable of Windows. (If you do this, you will be able to run the script from any location)
How to use renamex?
Usage: renamex [OPTIONS] EXTENSION1 EXTENSION2 Renames a set of files ending with EXTENSION1 to end with EXTENSION2. If none of the following options are provided, renaming is done in the current directory for all files with EXTENSION1. Where [OPTIONS] include: -v --verbose print details of files being renamed -d [directory] --directory [full path] rename files specified in the directory -f [filter] --filter [wildcard] use wildcard characters (* and ?) for renaming files -h --help show this help Examples: renamex htm html (rename all .htm files to .html in the current directory) renamex -v log txt (show verbose output while renaming all .log files to .txt) renamex -v -d "D:\images" JPG jpeg (rename all .JPG files located in D:\images to .jpeg) renamex -v -d "D:\movies" -f *2007* MPG mpeg (rename all .MPG files with 2007 in their names, in D:\movies to .mpeg)
The inside story
A day after I developed this script, I realized that Windows already has an inbuilt mechanism to change extensions of multiple files at once! One has to just execute the command "rename *.JPG *.jpeg" in our case. This script is still here in spite of that to just demonstrate the powers of batch scripting. Besides, I learnt a new scripting language this weekend. Definitely not unproductive.