Renaming multiple files en masse?
paul at xciv.org
Tue Apr 11 22:01:00 BST 2000
David Marsh at home <drmarsh at bigfoot.com> wrote:
> OK, this is a really dumb question (but hopefully an easy one)..
> Could some kind person tell me how to rename multiple files en masse?
> I'm not too much of a shell wizard, and was wondering how I would quickly
> knock together a script to do this.
> To give an example (well, actually _the_ specific example ;-) I need to
> rename a directory full of .html files into .htm files (ugh, I know).
Using /bin/sh aka bourne shell:
for i in *.html
mv $i `echo $i | sed 's/\.html$/.htm/'`
A bit hacky but it should do the job.
Basically loop through the *.html files, using mv to do the rename,
use of backticks to construct the new file name. The new file name
being constructed by piping the current one through sed and doing
a replace on the .html extension.
More information about the Ukfreebsd