@523311 Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
The behavior you're experiencing is because of how Robocopy interprets the source and destination paths when multiple folder names are provided as arguments.
Robocopy only copies the directory structure when you use the /e
flag. To copy files, you need to use the /s
flag.
If you run the command for each folder separately, it should work as expected. However, it is recommended to use the /MT
flag to enable multi-threaded copying, which can significantly improve performance.
When you run the command:
Robocopy "c:\folder" "destination-path" "a" "b" "c" /e /copy:dat
Robocopy interprets "a" "b" "c"
as file names rather than folder names, which results in copying only the folder structure without the files. This is because Robocopy treats any argument that does not end with a backslash () as a file name. So, in this case, it's not recognizing "a", "b", and "c" as folder names.
To copy the entire folder structure along with files and subdirectories, you should use wildcards to specify the folders. Here's how you can achieve that:
Robocopy "c:\folder" "destination-path" "a*" "b*" "c*" /e /copy:dat
By using "a*", "b*", and "c*" with asterisks as wildcards, you are telling Robocopy to match any folder that starts with "a", "b", or "c" respectively, and copy their contents along with subdirectories and files.
Regarding your second question, if you run the Robocopy command separately for each folder, specifying the individual folder paths as sources and destination, it should work correctly because Robocopy will treat each argument as a separate folder path and copy their contents along with files and subdirectories.
Robocopy "c:\folder\a" "destination-path\a" /e /copy:dat
Robocopy "c:\folder\b" "destination-path\b" /e /copy:dat
Robocopy "c:\folder\c" "destination-path\c" /e /copy:dat
This should , Robocopy will correctly copy the folder structures along with files and subdirectories from each specified folder to the corresponding destination folder.
For detailed information on RoboCopy : https://video2.skills-academy.com/en-us/azure/storage/files/storage-files-migration-robocopy
Additional inforamtion: For testing you can use Azcopy tool
Robocopy examples
If you still find any difficulties, please let me know I would like to closer on this issue
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.