:: Unclear to me what the last line does
ROBOCOPY %_source% %_dest% %_what% %_options%
I missed something essential. You have changed the names of your variables so you need to change their names in the last line as well.
ROBOCOPY %source% %dest% %what% %options%
Now I realise why you asked about what the last line does.
The %---% identify that you are referring to variables that you or Windows have set up.
Your
SET source=C:\Users\Me line defines a variable called
source and gives it the value
C:\Users\Me
So in your last line
%source%
Windows retrieves its value
C:\Users\Me
then uses that in the command.
The same applies to the other variables in your last line %dest% %what% %options%
when the script reads the %-----% it knows you mean a variable so it gets its value to use in their place.
So your last line
ROBOCOPY %source% %dest% %what% %options%
means
ROBOCOPY C:\Users\Me D:\MeCopy /B /MIR /S /R:5 /W:0
You can always write out the values in full every time but variables can add a great deal of power to batch files
Windows creates some variables of its own that you can use but in many batch files it's the ones you set up yourself that you are most interested in. If you open a Command window [not a PowerShell window] and enter the command
Set
on its own without anything following then it will list all the variables that Windows has set up already. Mine, for example, includes the line
USERNAME=denis
If, just for example, I was guiding you through doing something, I might suggest pasting this in the File explorer address bar
C:\Users\%UserName%\AppData\Roaming
so you could get straight to the folder I wanted to say something about. Windows would interpret %UserName% using the list I just got you to display so I could get you to the right folder without having to ask what your username was or giving you a long-winded and confusing explanation about how to get there.
I think you will now have lots of questions. I will answer them but I should also point out that if you are learning scripting from scratch your investment of time, effort & grey hair will be better rewarded by studying PowerShell, a well-structured scripting method that is entirely unlike the mish-mash of unstructured batch file commands that have evolved haphazardly over the last several decades.
- You can use almost all commands, such as RoboCopy, in PowerShell scripts but the way PowerShell refers to many things, including variables, is radically different.
- I've listed some PowerShell guides in my ditty
Batch file and PowerShell guides [post #7] - ElevenForum
All the best,
Denis