Re: rename files

From: Stephane CHAZELAS (this.address_at_is.invalid)
Date: 09/08/04


Date: 08 Sep 2004 14:10:09 GMT

2004-09-08, 09:57(-04), d0x:
> can any one help me out with this. I know somebody must have done it
> already.
>
> i have a directory with 901 files in it.
> i need a script the renames the files. basically i need it to take
> anything that is not a number,letter, or "." and change it to an "_".
>
> ie. "Charlie's Root.zip" - will become "Charlie_s_Root.zip"
[...]

Use zsh4.

autoload -U zmv # if not already in ~/.zshrc
cd /directory
zmv -n '(**/)(*)' '$1${2//[^.[:alnum:]]/_}'

Remove "-n" if you're happy with what zmv is going to do.

-- 
Stephane