r/Batch • u/hooperre • Nov 15 '17
Challenging Line of Batch Code (For a Newbie)
/r/scripting/comments/7cs0bw/challenging_line_of_batch_code_for_a_newbie/
2
Upvotes
r/Batch • u/hooperre • Nov 15 '17
3
u/jcunews1 Nov 15 '17
There's only one
doallowed on aforcommand. To execute multiple commands on aforloop, use command group. e.g.Or, command separator. e.g.
The first method is recommended.
That's not a valid syntax for
forcommand. See the documentation by typingfor /?.1
u/hooperre Nov 17 '17
/u/jcunews1
If you don't mind me calling you out here to avoid another post from me on the subreddit...
A lot of my issues seems to be coming from the way I name my pathway variables. For example:
My %source% variable works well every time I use it because I use
set source=%cd%.Now, I've read that spaces in file pathways will often mess up a code for obvious reasons. So in some of my codes, like my
%amiga_source%variable (%source%\amiga\), I have it writtenamiga_source="%source%\amiga\"and then it will wreak havoc in my code with faultyxcopyscripts (I guessxcopyis an older command?). When I view the output of an xcopy command, it will basically say"%source%"\amigaor something screwy.In short, what is the typical way to define a file pathway in some sort of variable? Is there a way to use the regular copy command to copy over directories?
1
u/Pyprohly Nov 16 '17
Fixing your sample:
An alternate way:
Another way: