[Techtalk] bash/perl script to rename files...

Laurel Fan laurel at freeshell.org
Fri Oct 26 18:35:04 EST 2001

On Fri, Oct 26, 2001 at 02:07:02PM -0400, Walt wrote:
> I need a perl script that replaces spaces
> in a filename with underscores...
> I'm sure that this can be achieved, I just
> don't know how to do it.

The unix faq describes how to change file names to lowercase
Changing spaces to underscores in filenames is similar.

This zsh script worked for me:

            for f in *; do
                mv $f `echo $f | tr ' ' '_'`
(replaces spaces with underscores for all the filenames in the

More information about the Techtalk mailing list