How to easily remove spaces from file names

Below is a simple one liner that will replace the spaces with an underscore for all files in the current directory.

find . -type f -name “* *” -maxdepth 1| while read src; do mv “$src” `echo $src | tr ” ” “_”`; done

Leave a Reply

Your email address will not be published. Required fields are marked *