Using robocopy with source and destination as variables

Completely new to writing scripts, I tried to find a solution through an Internet search, but I'm at a standstill, so I ask for help, please!

I am trying to use robocopy with a variable of both source and destination, differently for each, but I just can't get the correct syntax.

Hard code that I can work with normally:

robocopy C:\Users\me\Documents\a C:\Users\me\Documents\b

But I can not get it to work with variables. After reading, I tried, which looks like all the options below: "and% in / out, with and without Set, and none of them worked.

Set src="C:\Users\me\Documents\a"
Set dest="C:\Users\me\Documents\b"

robocopy %src% %dest%

Hopefully a clear explanation of what I'm trying to do if I don't ask for clarification. Thanks in advance for any help.

+4
5

, Robocopy . :
:

Set Today=%DATE:~0,3%
Robocopy "G:\folder A" "U:\%Today%\folder A"  ^
/S /XJD /R:25 /W:4 /NP /copyall ^
/LOG:"U:\%Today%\FolderALog.txt"
IF ERRORLEVEL 8 goto Badend

( )

Set Today=%DATE:~0,3%
Set source="G:\folder A"
Set target="U:\%Today%\folder A" 
Set Logname="U:\%Today%\FolderALog.txt"
Echo Source is %Source%
Echo Target is %Target%
Echo logfile named %Logname%
Pause
Robocopy %source% %target%   ^  
/S /XJD /R:25 /W:4 /NP /copyall  ^
/LOG:%Logname%
Pause

1- , :

Set Today=%DATE:~0,3%
Set source="G:\folder A"
Set target="U:\%Today%\folder A"
Set Logname="U:\%Today%\FolderALog.txt"
Echo Source is %Source%
Echo Target is %Target%
Echo logfile named %Logname%
Pause
Robocopy %source% %target% /S /XJD /R:25 /W:4 /NP /copyall  ^
/LOG:%Logname%
Pause

curt (^) DOS, , , , 'm "U:\%Today%\folder A ^". - , - . : , , . , , . , , , . RoboCopy , .

+3
set "src=C:\Users\me\Documents\a"
set "dest=C:\Users\me\Documents\b"

robocopy "%src%" "%dest%" 

. " " ,...

robocopy , xcopy. . , robocopy . , ,... , .

robocopy . , , .

+2

.bat, :

Set src="C:\Users\me\Documents\a"
Set dest="C:\Users\me\Documents\b"

robocopy.exe %src% %dest%

.exe

0

Set src=C:\Users\me\Documents\a
Set dest=C:\Users\me\Documents\b

robocopy %src% %dest% /E

/E - ,

0

XCOPY, !

:

xcopy "C:\Users\me\Documents\a" "C:\Users\me\Documents\b"

he will ask if the destination is a folder or file, so after you select the folder (dir), it will be copied!

hope this helps !: D

-2
source

All Articles