Remove Invalid characters from a filename

Categories General Info

To remove invalid characters like ? & etc. in a file name, use this simple script;

touch reminvchar.sh
vim reminvchar.sh

insert the following lines of code

for i in `find . -type f`
do
echo $i
mv $i `echo $i |tr ? _|tr = _ |tr ‘&’ ‘_’`
done

save the file using ‘:wq’ and then

chmod +x reminvchar.sh

and then run the file;

./reminvchar.sh

Leave a Reply