@echo off for /f %%i in ('dir PIL*.exe /B') do (call :SUB1 %%i) GOTO :EOF :SUB1 %1