0
我想只讀取批處理文件中的前兩行,並將它們存儲在兩個不同的變量中。我使用此代碼:批處理文件中的循環和變量
@echo off
for /f "delims=''" %%f in (red.txt) do (
echo file is: %%f
set /A Counter+=1
call :a %counter%
echo Counter After Increment: %Counter%
echo.
)
:a
if %Counter% equ 1 (set "file1=%f"
echo first file is: %file1%)
if %Counter% equ 2 (set "file2=%f"
echo second file is: %file2%)
if %Counter% equ 4 exit
echo Counter after for loop: %Counter%
pause
但變量'file1'和'file2'顯示空白。 任何思考如何去解決它?