Windows 如何组合两个批处理脚本,将它们放入一个批处理文件并按降序运行它们
嗨,我想采取两个批脚本,并结合成“一个”。我还希望现在的“一”批处理文件以降序运行 我可以使用Windows 如何组合两个批处理脚本,将它们放入一个批处理文件并按降序运行它们,windows,batch-file,cmd,Windows,Batch File,Cmd,嗨,我想采取两个批脚本,并结合成“一个”。我还希望现在的“一”批处理文件以降序运行 我可以使用调用功能,但是,我有三个批处理文件 我正在尝试将它们结合起来,并获得与从callbatchA+batchB.bat文件运行batchA.bat和batchB.bat相同的结果 e、 g callbatchA+B.batch,batchA.bat,batchB.bat 通过运行下面包含的concatfile.bat,我尝试了一个简单的concat copy callbatchA+B.bat+batchA.
调用
功能,但是,我有三个批处理文件
我正在尝试将它们结合起来,并获得与从callbatchA+batchB.bat文件运行batchA.bat和batchB.bat相同的结果
e、 g callbatchA+B.batch,batchA.bat,batchB.bat
通过运行下面包含的concatfile.bat,我尝试了一个简单的concat
copy callbatchA+B.bat+batchA.bat+batchB.bat combined_.bat
这不适用于下面的串联的文件示例
::CallScript
CALL C:\Users\Myname\Desktop\batchA.bat
CALL C:\Users\Myname\Desktop\BatchB.bat
::ScriptA
@echo off
setlocal EnableDelayedExpansion
CD "C:\deviceno\"
::only change these three lines
set "start=295" ::starts from this number
set "amount=10" ::amount of files created
set "length=5" ::
set /a "last=%start%+%amount%"
for /l %%i in (%start%,1,%last%) do (
set "folderName=0000000000%%i"
set "folderName=!folderName:~-%length%!"
md "!folderName!"
)
pausefor
::ScriptB
/D %%a in ("C:\deviceno\*.*") do xcopy /y /d C:\Source\*.*"%%a\"
我试图用goto:eof
编辑代码,如下所示,但到目前为止我没有运气
::ScriptA
@echo off
setlocal EnableDelayedExpansion
CD "C:\device_numbers\"
::only change these three lines
set "start=295" ::starts from this number
set "amount=10" ::amount of files created
set "length=5" ::
set /a "last=%start%+%amount%"
for /l %%i in (%start%,1,%last%) do (
set "folderName=0000000000%%i"
set "folderName=!folderName:~-%length%!"
md "!folderName!"
) DO CALL ::ScriptB
::ScriptB
p /D %%a in ("C:\device_numbers\*.*") do xcopy /y /d C:\Source\*.*"%%a\"
goto :eof
你是说这个吗
运行batchA.bat
并将batchA.bat
输出到batchB.bat
,然后运行batchB.bat
batchA | batchB
batchA & batchB
或者运行batchA.bat
,然后运行batchB.bat
batchA | batchB
batchA & batchB
我想你是想这么做:
::CallScript
@echo off
CALL :ScriptA
CALL :ScriptB
pause
goto :eof
:ScriptA
setlocal EnableDelayedExpansion
CD "C:\deviceno\"
::only change these three lines
set "start=295" ::starts from this number
set "amount=10" ::amount of files created
set "length=5" ::length of fileNames
set /a "last=%start%+%amount%"
for /l %%i in (%start%,1,%last%) do (
set "folderName=0000000000%%i"
set "folderName=!folderName:~-%length%!"
md "!folderName!"
)
goto :eof
:ScriptB
for /D %%a in ("C:\deviceno\*.*") do xcopy /y /d "C:\Source\*.*" "%%a\"
goto :eof
这将是一个文件,使用子例程创建和复制文件
我建议您看看如何更好地理解呼叫标签的工作原理,也许是这样的
@ECHO关闭
SETLOCAL
::为演示设置一些数据项
设置/a fred=3
一套/a乔=8
集/a=10
调用外部添加结果%fred%%charlie%
回显%结果%
调用外部添加结果%fred%%charlie%%joe%
回显%结果%
调用外部减法结果%fred%%charlie%
回显%结果%
调用外部连接结果%fred%xyz%charlie%
回显%结果%
后藤:EOF
外部.bat
:: @echo off
setlocal enabledelayedexpansion
goto %*
:add
shift
set $=%1&shift
set /a $t=0
:addloop
set /a $t+=%1
shift
if "%1" neq "" goto addloop
:commonexit
endlocal&set %$%=%$t%
goto :eof
:subtract
shift
set $=%1&shift
set /a $t=%1-%2
goto commonexit
:concatenate
shift
set $=%1&shift
set "$t="
:concatloop
set "$t=%$t%%1"
shift
if "%1" neq "" goto concatloop
goto commonexit