Renaming multiple files en masse?

Mark Ovens mark at
Tue Apr 11 23:26:04 BST 2000

On Tue, Apr 11, 2000 at 10:01:00PM +0100, Paul Civati wrote:
> David Marsh at home <drmarsh at> 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
>   do
>       mv $i `echo $i | sed 's/\.html$/.htm/'`
>   done



for i in `ls *.html`
	 mv $i `basename $i .html`.htm

Note that those are backticks, not single quotes.

> 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.
> -Paul-
> ------ FreeBSD UK User's Group  -  Mailing List ------

        ...and on the eighth day God created UNIX
      FreeBSD - The Power To Serve
      My Webpage
mailto:mark at   

More information about the Ukfreebsd mailing list