@echo off
setlocal
REM %random:~0,n%的n为产生数字的最多位数
Set N=%random:~0,1%
:getfilename
Set /p file=请拖放一个文件到这里:
If not defined file Goto getfilename
If not exist %file% (Echo 错误:文件%file%无法找到。& Exit /b 1)
If "%N%" == "1" For /f "usebackq tokens=1,*" %%i In (%file%) Do (Echo 第%N%行:%%i %%j&endlocal & Exit /b 0)
Set /a skip=N-1
For /f "usebackq tokens=1,* skip=%skip%" %%i In (%file%) Do (Echo 第%N%行:%%i %%j&endlocal & Exit /b 0)