Remove space in file name or path name

Written on 22 July 2016

Some time you want to make a loop in list of file or directory. So remove space help done this task easier.

find -name "* *" -type d | rename 's/ /_/g'    # do the directories first  
find -name "* *" -type f | rename 's/ /_/g'  

Now make loop

for file in ls ; do  
echo "Do Some Thing"