Feb 18 2020 10:24 PM - edited Feb 18 2020 10:27 PM
Hi!
I'm writing a .bat script to copy exactly one file between two harddrives.
First I write this:
SET A1=%1 <source>
SET A2=%2 <destination>
SET A3=%3 <file>
This works: (folders are hard-coded)
ROBOCOPY C:\test\ "D:\Folder with spaces\" %A3%
This does not work: (all arguments)
ROBOCOPY %A1% %A2% %A3%
When it fails, it can be of several reasons:
Robocopy cannot find the file.
Robocopy messes up on the folders, so the <source> ends at the first space in <destination>
The following tweaks does not either work:
Replacing SET A1=%1 with SET A1="%~1" , (along with the rest of the arguments)
Omitting spaces, so %A1% %A2% %A3% becomes %A1%%A2%%A3% .
Do you have any suggestions to what I can do to get Robocopy to work with all the arguments, with no hard-coding?
Feb 19 2020 09:59 AM
Feb 19 2020 11:33 AM
I'm sorry I didn't state this in the original post.
I'm using Windows 8.1 Pro.
I couldn't find a separate community specifically for 8.1, so I went for 10.