remove special characters from filename recursively

hi:

i have several thousand files from users and of course they use all kind of characters on filenames. I have things like:

My special report (1999 ) Lisa & Jack's work.doc

crazy.

How do I remove all this characters in the current dir and subdirs too?

Thanks.

find . -type f -print | while read file
do
    file_clean=$( echo ${file} | tr " ()&'" "_____" )
    echo $file $file_clean
done

Note: that's 5 underscores in the second argument to tr
If it works as intended (I haven't tested it), change the echo in line 4 to mv.

That script will fail for many reasons.

First, you don't want to find all files, only those whose name contains a space:

find . -type f -name '* *' -print |

Second, your read loop will strip leading or trailing spaces from the filenames (probably not a problem, but you never know) and remove any backslashes (also probably not a problem, but why risk it?):

 while IFS= read -r file

Third, modern versions of tr do not require the replacement to be repeated:

file_clean=$( echo "$file" | tr " ()&'" "_" )

Fourth, the mv line will fail when a filename contains a space (which, given the problem you are trying to solve, is always).

echo "$file" "$file_clean"

In bash and ksh93, you don't need tr:

file_clean=${file//[ ()&\']/_}

hi:

I ended up using this

 find . -print | while read file
do
  file_clean=${file//[ ()&\'\,]/_}
  mv "$file" "$file_clean"
done

since I wanted to rename folders too and there were some filenames with

my docs, photos, and more/year 1999, 2000.doc

crazy users!

thanks.