nntp2http.com
Posting
Suche
Optionen
Hilfe & Kontakt

Custom variables in FOR loop - is this possible?

Von: Andreas Eibach (aeibach@mail.com) [Profil]
Datum: 04.10.2009 08:13
Message-ID: <7iqs5tF32rrarU1@mid.uni-berlin.de>
Newsgroup: alt.msdos.batch.nt
Hi everybody,
first I should tell WHY I need this.

I want to execute a routine on each partition I have, but these may vary
from time to time, e. g. network drives which have a letter assigned, etc.

-- begin code --

set d3=C
set d4=D

for /D %%d in (%d3 %d4) do call :extroutine %%d %%1
goto :quit

:extroutine
echo.
echo Doing something
echo.
:end

:quit

-- end --

My plan is to have a variable for EACH partition which, on change of setup,
I could simply set empty (set %d<number>= ) to avoid ugly "Drive not
found"
messages.
But apparently FOR does not accept variables in the (set).

For example:

set d3=C
set d4
set d5=E

would (or should) get transformed from

for /D %%d in (%d3 %d4 %d5) do call :extroutine %%d %%1

to

for /D %%d in (C E) do call :extroutine %%d %%1

How could I do this?
It would also be OK to have an external file read out in which the valid
drive letters are listed.

-Andreas

[ Auf dieses Posting antworten ]

Antworten