test_1.bat | @echo off | | | | set "SrcFile=C:\Test\1.txt" | | | | set "DstRow=2" | | setlocal enabledelayedexpansion | | for /f "tokens=1* delims=:" %%i in ('findstr /n .* "%SrcFile%"') do ( | | set /a "CurRow+=1" | | if !CurRow! equ %DstRow% ( | | echo,%%j | | goto :End | | ) | | ) | | | | :End | | pauseCOPY |
test_2.bat | @echo off | | | | set "SrcFile=C:\Test\1.txt" | | | | set "DstRow=2" | | set "CurRow=0" | | for /f "tokens=1* delims=:" %%i in ('findstr /n .* "%SrcFile%"') do ( | | if %%i equ %DstRow% ( | | echo,%%j | | goto :End | | ) | | ) | | | | :End | | pauseCOPY |
test_3.bat | @echo off | | | | set "SrcFile=C:\Test\1.txt" | | | | set "DstRow=2" | | | | if %DstRow% equ 1 ( | | set /p str=<"%SrcFile%" | | call echo,%%str%% | | goto :End | | ) | | set /a "IgnoreCount=DstRow-1" | | call :GetRow %%IgnoreCount%% | | goto :eof | | | | :GetRow | | for /f "skip=%1 delims=" %%i in ('type "%SrcFile%"') do ( | | echo,%%i | | goto :End | | ) | | | | :End | | pauseCOPY |
|