0
votes

Can anybody tell me how to do the following in in a DOS batch script? (*.bat):

•Create a folder only under different folders on remote machines

In more detail, I want to create a folder named TMP on the

COMPUTER1/D/market1/TMP
COMPUTER1/D/market2/TMP
COMPUTER2/D/market1/TMP
COMPUTER2/D/market2/TMP

I can do a FOR loop to run the batch on different computer but I need to create this TMP directory under a diferent folder ie market1 market2 market3 market4 and so on

Thanks

2

2 Answers

0
votes

Then just add a variable counter to your for loop and call your batch script with argument...:

script.bat 2

And in batch script then retrieve the argument....

mkdir  market%1

EDIT: when I look at your comment it looks like you are doing it in one script then you want to use something like:

first.bat:

    set count=1
    set hostname=computer
    setlocal enabledelayedexpansion

    FOR /F %%C IN (%FILENAME%) DO ( files\psexec -c 
                                    mkdir "D:\Program Files\work\!hostname!-!count!\tmp" /s /q
                                    if ERRORLEVEL 1 (
                                        exit /b !ERRORLEVEL!
                                    )
                                    echo Starting %%C 
                        set /a count=!count!+1
        )
0
votes

This may help you: it will create market1\TMP to market255\TMP on the two computers.

@echo off
for %%a in (computer1 computer2) do (
   for /L %%b in (1,1,255) do (
      md "\\%%a\D\market%%b\TMP"
   )
)