while read -d $'\0' file; do [ -f "$file" ] || continue newname=${f//[^a-zA-Z0-9_.]/_} [ "$file" = "$newname" ] && continue [ -f "$newname" ] && continue echo "$file" echo "$newname" echo "________________________________" done < <(find . -type f -print0) if I replace echo by mv then I get errors like this: mv: cannot move `./audio/hafez/Abdel_Halim_Hafez_-_Ahwak.mp3' to `': No such file or directory here is the ouput: ./audio/hafez/Abdel_Halim_Hafez_-_Ahwak.mp3 ________________________________ ./audio/hafez/Abdelhalim_Hafez_-_Gabbar.mp3 ________________________________ ./audio/hafez/Abdel_Halim_Hafez_-_Asmar_Ya_Asmarani.mp3 ________________________________ ./audio/hafez/Abdel_Halim_Hafez_-Musica_Arabe_-_Bahlam_Beek.mp3 ________________________________ ./audio/hafez/abdelhalim_hafez_jana_l'hawa.avi