Script run on Window OS

Posted on 2012-09-05
Last Modified: 2012-09-07
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"

Question by:AXISHK
    LVL 1

    Expert Comment


    Author Comment

    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 ?

    LVL 39

    Accepted Solution

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Suggested Solutions

    The way I use Experts Exchange to assist me in analyzing and diagnosing a problem is I first enter a Verbose Question at Experts Exchange like: Office 2007 will hang when opening and saving files I then launch WordPad (any text editor will do) an…
    The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
    Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now