Delete spaces from filenames

Written by
Date: 2013-06-03 16:12:13 00:00

Spanish version

Sometimes filenames include spaces, specially song filenames and also pictures / photos filenames.

That is OK until you need to batch manage those files, then the script usually have problems working on those files with spaces in its filenames.

Here is a simple way to get rid of spaces in filenames if you are using Unix-kind Operating System like Linux or Mac OS X

find . -depth -name '* *' | while IFS= read -r f ; do mv -i "$f" "$(dirname "$f")/$(basename "$f"|tr ' ' _)" ; done

That is it.