On Bash, I used the following script to replace the empty spaces in some directories with an underscore:
for dir in */; do
mv "${dir}" "${dir// /_}"
done
This did the trick but still received unnecessary output for directories that did not have an empty space to be replaced:
mv: cannot move 'directory1' to a subdirectory of itself, 'directory1/directory1'
Is there a more succinct way to carry this out in bash that doesn't result in a message for each of those directories that was unaffected?
Thanks