please explaine this command line

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
USB 3
Posts: 3
Joined: 12 Sep 2010 03:43

please explaine this command line

#1 Post by USB 3 » 13 Sep 2010 09:48

for /f "tokens=1,2 delims==" %%a in (key.txt) do (set SN=%%a )

aGerman
Expert
Posts: 4705
Joined: 22 Jan 2010 18:01
Location: Germany

Re: please explaine this command line

#2 Post by aGerman » 13 Sep 2010 10:04

This command line loops over the content of key.txt.
If the content is something like x=y then it works as follows:

delims== means that the data separator is the equal sign
tokens=1,2 means that you get the first and the second part of an equal-sign-separated line
%%a means that the first part is saved to the dynamic variable %%a (the second is saved to %%b ...)
set SN=%%a means that the content of %%a is saved to SN, so you can work with variable %SN% after the FOR loop.

For my example you would get x in %SN%.

Regards
aGerman

USB 3
Posts: 3
Joined: 12 Sep 2010 03:43

Re: please explaine this command line

#3 Post by USB 3 » 13 Sep 2010 10:16

Thanks a lot :D

Post Reply