Sunday, January 3, 2010

Renaming Multiple Files

My first shell script that I actually implemented*, shamelessly cobbled from the internet. This comes in handy sometimes.

for i in *; do mv $i Fe2tHMe${i#Fe2tMeMe}; done

The Fe stuff is just whatever struck my fancy. Basically, if you want to rename all files in a folder from

Fe2tMeMe*

to

Fe2tHMe*

where * means wildcard, this is one way to do it. I believe the # means "remove from beginning of existing name".

*The first script I've ever seen was a fancy little search-and-replace thing invented on-the-spot by a crazy-brilliant computer-science major acquaintance of mine; to this day, I still don't quite know how to actually get it to run.

No comments: