The following worked for me to find all files containing spaces:
find ./ -type f | grep " "
To also rename all found files to the same filename without the spaces, run the following:
find ./ -type f | grep " " | while read file; do mv "$file" ${file// }; done
Ways to configure the above script:
- To rename only directories, change
-type f to -type d - To use git-aware rename, change
do mv to do git mv - To rename differently, change
${file// }; to ${file// /[some-string]};. For example, to replace the spaces with "_", use: ${file// /_}; (notice the leading "/")
ls *" "*?find . -name "* *"?echo *" "*also works