Move all contents from a folder to another with shell script
Why does this work?
mv /Users/diogosaraiva/Music/Youtube/Novas/* /Users/diogosaraiva/Music/Youtube/Tratadas
…but the commands below don't work?
mv "/Users/diogosaraiva/Music/Youtube/Novas/*" "/Users/diogosaraiva/Music/Youtube/Tratadas"
I had to rename the folder "Youtube" from "Youtube - Downloads", just because this don't work:
mv "/Users/diogosaraiva/Music/Downloads - Youtube/Novas/*" "/Users/diogosaraiva/Music/Downloads - Youtube/Tratadas"
I want integrate this in an Automator app. Is there a better way to move all contents from an folder to another with Automator.app?
The space character is used by bash
to separate different parameters to a command so you need to protect/escape it if it occurs in filenames (or other parameters):
mv /Users/diogosaraiva/Music/Downloads\ -\ Youtube/Novas/* /Users/diogosaraiva/Music/Downloads\ -\ Youtube/Tratadas
You can also use quotes to protect the space characters from being misinterpreted by the shell but need to move the *
outside the quotes then to allow wildcard expansion:
mv "/Users/diogosaraiva/Music/Downloads - Youtube/Novas/"* "/Users/diogosaraiva/Music/Downloads - Youtube/Tratadas"