• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • 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"

Tkx
0
AXISHK
Asked:
AXISHK
1 Solution
 
alisafiaCommented:
0
 
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 ?

Tkx
0
 
Krzysztof PytkoSenior Active 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

tokens=1-5

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

i.e.

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

Regards,
Krzysztof
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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