Remove whitespaces from filenames in Linux
linux, regex, rename
Solution
You could do something like this:
IFS="\n"
for file in *.jpg;
do
mv "$file" "${file//[[:space:]]}"
done
Problem
I have hundreds of jpg files in different folders like this: - 304775 105_01.jpg - 304775 105_03.jpg - 304775 105_05.jpg - 304775 105_07.jpg - 304775 105_02.jpg - 304775 105_04.jpg - 304775 105_06.jpg Basically, I need to remove the SPACES. I already know the command to change the spaces into underscores: ``` $ rename "s/ /_/g" * ``` But I do not need the underscores in this case. I just need to remove the space. I tried the following, but it didn't work: ``` $ rename "s/ //g" * ``` Any help would be appreciated.