change file extensions on Mac OSX

Being new tro the Mac, I wanted to figure out how to change a bunch of file extensions at once.I had to change a bunch of .html files to .cfm and if using the Mac. They are really just UNIX commands, so I bought the book UNIX for Mac.

Beneath Mac OS X Tiger’s easy-to-use Aqua interface lies a powerful Unix engine. Mac users know that Unix is at their fingertips, if only they knew how to access it. Learning Unix for Mac OS X Tiger provides Mac users with a user-friendly tour of the Unix world concealed beneath Mac OS X’s hood and shows how to make the most use of the command-line tools.

To fix this issue I just opened terminal and use this command.

[box] for file in `ls *.html`; do mv $file `basename $file .html`.cfm; done[/box]

Please note you must be in the current directory to make this change!

This is something I found really handy today, as I had to change the extensions to over 1000 files, i wish this was recursive, but it still was a huge time saver!

Leave a Reply

Your email address will not be published. Required fields are marked *