0

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

4

2 回答 2

0

然后只需将变量计数器添加到您的 for 循环并使用参数调用您的批处理脚本...:

script.bat 2

然后在批处理脚本中检索参数....

mkdir  market%1

编辑: 当我查看您的评论时,您似乎是在一个脚本中执行此操作,然后您想使用类似的东西:

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
        )
于 2013-08-23T11:38:13.637 回答
0

这可能会对您有所帮助:它将market1\TMPmarket255\TMP两台计算机上创建。

@echo off
for %%a in (computer1 computer2) do (
   for /L %%b in (1,1,255) do (
      md "\\%%a\D\market%%b\TMP"
   )
)
于 2013-08-23T13:26:54.263 回答