@echo off SETLOCAL ENABLEEXTENSIONS if exist "%~f1" ( if %~z1 GEQ 20480 ( start "" "%ProgramFiles%\Windows NT\Accessories\wordpad.exe" "%~f1" ) else ( start notepad "%~f1" ) ) Edit: The %~z syntax only works for parameters and FOR loops, for a hardcoded name you can use a helper function:
@echo off SETLOCAL ENABLEEXTENSIONS goto main :getfilesize set %1=0 if exist "%~f2" set %1=%~z2 @goto :EOF :main set myfile=test.txt call :getfilesize mysize "%myfile%" if %mysize% GEQ 20480 ( start "" "%ProgramFiles%\Windows NT\Accessories\wordpad.exe" "%myfile%" ) else ( start notepad "%myfile%" )