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