Batch File Question

Archived from groups: microsoft.public.windowsxp.general (More info?)

I have a text file with a list of names, I would like to redirect this file
somehow to the md/mkdir command so that it will read the file and make a
directory for each entry in the text file..

Is this possible? If so how do i go about doing something like this. Thanks.
5 answers Last reply
More about batch file question
  1. Archived from groups: microsoft.public.windowsxp.general (More info?)

    I would copy and paste the md command into the column before all the names
    then save it as a .bat file. Copy the .bat file to the root of the drive I
    want these folders in and execute the bat file.


    "Adrian" <Adrian@discussions.microsoft.com> wrote in message
    news:02D694FA-E55D-42F2-BAF2-87C3B664D25E@microsoft.com...
    >I have a text file with a list of names, I would like to redirect this file
    > somehow to the md/mkdir command so that it will read the file and make a
    > directory for each entry in the text file..
    >
    > Is this possible? If so how do i go about doing something like this.
    > Thanks.
  2. Archived from groups: microsoft.public.windowsxp.general (More info?)

    I'm not sure if there are any loops allowed in batch files. You could do it
    using an AutoIT script (http://www.autoitscript.com/autoit3/index.php) which
    is really simple. Just replace names.txt with whatever your text file is,
    and it will read in all the file one line at a time, and then create a
    directory with that name (from wherever the script is run. AutoIT is a free
    scripting language used to automate installs and other things.

    ;*****Beginning of Program*****
    #include <array.au3>
    #include <file.au3>
    #include <string.au3>
    Dim $names
    _FileReadToArray("names.txt",$names)

    For $i=1 to $names[0]
    $val=DirCreate(StringStripCR($names[$i]))
    Next
    ;*****End of Program*****


    "Adrian" wrote:

    > I have a text file with a list of names, I would like to redirect this file
    > somehow to the md/mkdir command so that it will read the file and make a
    > directory for each entry in the text file..
    >
    > Is this possible? If so how do i go about doing something like this. Thanks.
  3. Archived from groups: microsoft.public.windowsxp.general (More info?)

    of corse you can do loops in batch files:

    FOR %A IN (list) DO command [ parameters ]

    Now, whether you can make a list of directory names in another file and
    then pipe them into the command using the pipe and % variables tokens
    is debateable.

    If the list doesnt vary, simpler to just write a load of MKDIR commands
    in a batch file. If the list does vary, then the above solution is the
    only way, but its complicated.

    look at http://www.robvanderwoude.com/index.html for a detailed
    explanation.


    --
    guestfromhell
    ------------------------------------------------------------------------
    guestfromhell's Profile: http://www.iamnotageek.com/member.php?userid=12490
    View this thread: http://www.iamnotageek.com/showthread.php?t=1819079249
  4. Archived from groups: microsoft.public.windowsxp.general (More info?)

    "Adrian" <Adrian@discussions.microsoft.com> wrote in message
    news:02D694FA-E55D-42F2-BAF2-87C3B664D25E@microsoft.com...
    > I have a text file with a list of names, I would like to redirect this
    file
    > somehow to the md/mkdir command so that it will read the file and make a
    > directory for each entry in the text file..
    >
    > Is this possible? If so how do i go about doing something like this.
    Thanks.

    This is quite easy:

    @echo off
    for /F %%a in (c:\DirList.txt) do md %%a

    or, if your names contain embedded spaces:

    @echo off
    for /F "tokens=*" %%* in (c:\DirList.txt) do md "%%*"
  5. Archived from groups: microsoft.public.windowsxp.general (More info?)

    Batch files under Win2000/XP are surprisingly powerful. They
    allow loops, if/then/else statements, string manipulation and lots
    more. The only problem is that they are totally unstructured.


    "Jason Ryon" <JasonRyon@discussions.microsoft.com> wrote in message
    news:387E32C9-2BB5-41CF-8DD7-9F14E3DE0320@microsoft.com...
    > I'm not sure if there are any loops allowed in batch files. You could do
    it
    > using an AutoIT script (http://www.autoitscript.com/autoit3/index.php)
    which
    > is really simple. Just replace names.txt with whatever your text file is,
    > and it will read in all the file one line at a time, and then create a
    > directory with that name (from wherever the script is run. AutoIT is a
    free
    > scripting language used to automate installs and other things.
    >
    > ;*****Beginning of Program*****
    > #include <array.au3>
    > #include <file.au3>
    > #include <string.au3>
    > Dim $names
    > _FileReadToArray("names.txt",$names)
    >
    > For $i=1 to $names[0]
    > $val=DirCreate(StringStripCR($names[$i]))
    > Next
    > ;*****End of Program*****
    >
    >
    > "Adrian" wrote:
    >
    > > I have a text file with a list of names, I would like to redirect this
    file
    > > somehow to the md/mkdir command so that it will read the file and make a
    > > directory for each entry in the text file..
    > >
    > > Is this possible? If so how do i go about doing something like this.
    Thanks.
Ask a new question

Read More

Microsoft Command Prompt Windows XP