Rename files with spaces to underscore in all subcategories
<p>I have category /products/ and subcategories. I need a one line command to remove spaces from name to underscore and if its 2 spaces put only 1 underscore. Rename command doesn't work on this server.
I've been using <code>for file in *; do mv "$file" echo $file | tr ' ' '_' ; done</code> but it doesn't work for subcategories what i have a lot, plus if there is 2 spaces this command gonna make 2 underscores and I need different.
Please advise </p>