@echo off setlocal EnableExtensions EnableDelayedExpansion if "%~1"=="" ( echo Usage: %~nx0 ^ [rows] exit /b 2 ) set "FILE=%~1" if not exist "%FILE%" ( echo File not found: %FILE% exit /b 2 ) if exist "%FILE%\" ( echo Path is a directory: %FILE% exit /b 2 ) set "COUNT=%~2" if "%COUNT%"=="" set "COUNT=10" echo %COUNT%| findstr /r "^[1-9][0-9]*$" >nul if errorlevel 1 ( echo Rows must be a positive number. exit /b 2 ) set "HEADER=" set /p "HEADER="<"%FILE%" if not defined HEADER ( echo File is empty: %FILE% exit /b 1 ) echo Header: !HEADER! echo ---------------------------------------- set /a SHOWN=0 for /f "usebackq skip=1 delims=" %%L in ("%FILE%") do ( echo(%%L set /a SHOWN+=1 if !SHOWN! geq %COUNT% goto :done ) :done echo ---------------------------------------- echo Shown data rows: !SHOWN! exit /b 0