Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I have just started learning batch scripting.., I want to know why we use the below variables
%%a,%%b,%%c,%%d,%%e,%%f,%%i like this we have so many variales..are these variables are used for any specific purpose?
and what are these number variables for %%1 , %%2, %%3 ,%%4 ,%%5 ,%%6,%%7,%%8,%%9
Please let me know why and where are these variables used.Regards,
Satyam

%%a, %%b etc are generally used in FOR loops, such as: for %%a in (*.*) do echo %%a
You can use any letter you want, it doesn't matter.
%1, %2 etc are used on the command line to specify optional arguments.
Take for example this script:
@echo off
set filename=%0
set arg1=%1
set arg2=%2
echo %arg1%
echo %arg2%
echo This file is called %filename%save that as script.bat, then on the command line: script testARG1 testARG2
The following would be echo'd to STDOUT:
testARG1
testARG2
This file is called script.batYou can get more info on the use of these variables with the following commands:
for /?
set /?

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |