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
find
expression that would produce a list of directories that contain one or more spaces in their name, and see where that takes you. Or just stick anif
statement in your existing loop...if test "$dir" != "${dir// /_}"; then mv "${dir}" "${dir// /_}"; fi