http://www.gautamk.com/blog/2012/09/07/remove-whitespace-from-all-filenames/
Bash:
for i in * ; do
if [ $i != ${i//[[:space:]]} ] ; then
mv $i ${i//[[:space:]]}
fi
done
Outro por chepner
for old in *; do
new="${old//[[:space:]]}"
[[ $old = $new || -f $new ]] || mv "$old" "$new"
done
Pitão :
import os
for f in os.listdir("."):
r = f.replace(" ","")
if( r != f):
os.rename(f,r)
Aqui está a questão stackoverflow relacionada