Mithun Sreedharan Mithun Sreedharan - 1 year ago 74
Linux Question

Linux - Replacing spaces in the file names

I have a number of files in a folder, and I want to replace every space character in all file names with underscores. How can I achieve this?

Answer Source

This should do it:

for file in *; do mv "$file" `echo $file | tr ' ' '_'` ; done
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download