Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
batchcc
- Posts: 139
- Joined: 17 Aug 2015 06:05
-
Contact:
#1
Post
by batchcc » 09 Nov 2016 14:57
I have a batch file with a large amount of variables now rather than adding this to the beginning of the file is there an easy way to resset all the variables?
Code: Select all
set var1=
set var2=
set var3=
set var4=
set var5=
set var6=
set var7=
set var8=
...
Thank you!
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#2
Post
by aGerman » 09 Nov 2016 16:10
You have to undefine them separately but you could use loops.
Code: Select all
for /l %%i in (1 1 8) do set "var%%i="
or
Code: Select all
for /f "delims==" %%i in ('set var') do set "%%i="
or
Code: Select all
for %%i in (a_variable another_variable another_different_variable) do set "%%i="
Steffen
-
dbenham
- Expert
- Posts: 2461
- Joined: 12 Feb 2011 21:02
- Location: United States (east coast)
#3
Post
by dbenham » 09 Nov 2016 16:26
The only time you don't need individual SET statements is when you are initializing a series of numeric values. For example, you could initialize four variables to 0:
Dave Benham