わかりました。これについていくつか質問がありますが、それぞれが2番目のbatファイルの使用CALL
とexit \b
/またはを確認していると言ってgoto eof
いますが、何らかの理由でこれが機能しないので、両方を試しました。バッチファイルは実行後に毎回終了します最初の呼び出しステートメント:
バッチファイル1(myscript.bat):
:@echo off
del files
dir /B /O-D | find "test2" > tmp
dir /B /O-D | find "test3" > tmp2
CALL head 1 tmp > files
CALL head 1 tmp2 >> files
head.bat:
@echo off
if [%1] == [] goto usage
if [%2] == [] goto usage
call :print_head %1 %2
goto :eof
REM
REM print_head
REM Prints the first non-blank %1 lines in the file %2.
REM
:print_head
setlocal EnableDelayedExpansion
set /a counter=0
for /f ^"usebackq^ eol^=^
^ delims^=^" %%a in (%2) do (
if "!counter!"=="%1" goto :eof
echo %%a
set /a counter+=1
)
goto :eof
:usage
echo Usage: head.bat COUNT FILENAME
実行:
C:\ Users \ ots> myscript.bat
C:\ Users \ots>delファイル
C:\ Users \ ots> dir / B / OD | 「test2」を検索1>tmp
C:\ Users \ ots> dir / B / OD | 「test3」を検索1>tmp2
C:\ Users \ ots> CALL head 1 tmp 1> files
C:\ Users \ ots>
2番目の「tmp2」コールラインを実行するにはどうすればよいですか?
ありがとう!