嗨,我想采取两个批处理脚本,并将其合并为“一个”。 我也想现在的“一个”batch file以降序运行。
我可以使用CALL
函数,然后我有三个batch file。
我正在尝试将它们结合起来,并达到相同的结果,如果我必须从callbatchA + batchB.bat文件运行batchA.bat和batchB.bat
例如callbatchA + B.batch,batchA.bat,batchB.bat
我通过运行下面包含的concatfile.bat来尝试一个简单的文件concat
copy callbatchA+B.bat+batchA.bat+batchB.bat combined_.bat
下面的concatenated
文件没有工作的例子
::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
我想你正在尝试这样做:
::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 off SETLOCAL :: set up some data items for demo SET /a fred=3 SET /a joe=8 SET /a charlie=10 CALL external add result %fred% %charlie% ECHO %result% CALL external add result %fred% %charlie% %joe% ECHO %result% CALL external subtract result %fred% %charlie% ECHO %result% CALL external concatenate result %fred% xyz %charlie% ECHO %result% GOTO :EOF
external.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
你的意思是?
运行batchA.bat
并将batchA.bat
输出到batchB.bat
,然后运行batchB.bat
batchA | batchB
或运行batchA.bat
,然后运行batchB.bat
batchA & batchB