Reputation: 244
What's the difference between @ an non @ command in batch script? Eg, what's the difference between @IF and IF
One more question: What's the difference between % and %% in batch script? Eg, what's the difference between %G and %%G
Thanks.
Upvotes: 0
Views: 863
Reputation: 6657
@
at the beginning of a line will execute the line but not write it to the output. It's like turning echo off
just for that line. See What does @ mean in Windows Batch scripts?
%%
is used in for
loops inside a batch file to escape a variable name you want to "declare". For example:
for %%a in (*.txt) do ( echo %%a )
If you write the same for
loop but not in a batch file, you would not double the %
:
for %a in (*.txt) do ( echo %a )
I have never understood why, I just know that's the way it is. :-) Maybe someone else can elaborate.
Upvotes: 3