[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

Script run on Window OS

for /F " tokens=1 " %%I IN (D:\servers.txt) DO call D:\SendOut %%~nI

for /F "tokens=1 delims=:" %%I IN (c:\SR.txt) DO set ss="%%I"

Can anyone explain how these two line mean ? Tkx

What's the tokens, delims, the different parameter %%~nI and "%%I"

1 Solution
AXISHKAuthor Commented:
for /F "tokens=1 delims=:" %%I IN (c:\SR.txt) DO set ss="%%I"
now %ss% >> C:\%1.txt

Still couldn't understand what these two lines mean ? Any idea ?

Krzysztof PytkoActive Directory EngineerCommented:
OK, let's try

tokens - means how many variables in a line you want to declare (by default 1)
When you want to define 5 variables in a line and there is enough data, this looks like


delims - means what character is separating variables in a line (by default space)

so, declaring "tokens1-5 delims=," tells the system to create 5 variables (one by one) reading a lne and when comma is found then new variable is set up

%i or %%i - this is a letter for the first variable (you may use any :) ) single % is used when you type syntax manually in command-line and double %% when use use that in batch files

in ('command') ("string") (file path) - means that variables should be searched in output from command, defined string or in a file

do - start executing another command which uses variables

set ss =%%I - means define system variable named SS and put there value from the first variable (%%I)

%ss% >>c:\%1.txt - %varName% is used to display value of defined variable. As you can see you have defined it before. >> means rdirect output from variable to file instead of screen in append mode (single > means overwrite)

and c:\%1.txt - means save data on C-Drive using %1 name (variable) as a text file name. But %1 is used when you run batch with parameter


file.bat FileName - then file will be created on C:\FileName.txt


Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now