REM foo.bat @echo OFF IF "%1" == "process" GOTO processFile GOTO convertAll :convertALL FOR %%f IN (c:\temp\*.txt) DO CALL %0 process "%%f" GOTO end :processFile SET in=%2 perl -p -i -e "s/change this/to this/g" %in% del %in%.bak GOTO end :end