megan@elon (Megan Squire)

Dr. Megan Squire's blog -- Elon University, Department of Computing Sciences

Friday, April 21, 2006

Batch change extension of files on the unix command line

Everytime I go to bulk change filenames on the commandline I feel depressed directly afterwards because of the hideousness of the syntax. Today I learned about the 'basename' command (via this article Batch change extension of files on the unix command line). It works like this:
# rename every *.htm file *.html
for f in *htm ; do mv $f `basename $f htm`html;done
Works like a charm!!