[wplug] changing extensions?

Brandon Poyner bpoyner at gmail.com
Wed Mar 28 12:48:54 EST 2007


On 3/28/07, Mike Griffin <mike at nbi.edu> wrote:

> Point noted.
>
> Best to keep with my first example, which will work in every instance.

It will work in most instances, but not every.

$ touch "some file.htm"
$ for i in *.htm; do mv $i `basename $i .htm`.html; done
basename: too many arguments
Try `basename --help' for more information.
mv: when moving multiple files, last argument must be a directory
Try `mv --help' for more information.

You need to insert quotes during the 'mv' to prevent that problem.

$ for i in *.htm; do mv "$i" "`basename "$i" .htm`.html"; done

Perhaps as Eric pointed out, 'rename' is a better solution here.

--
Brandon
Kiva.org - Make a small loan, Make a big difference


More information about the wplug mailing list