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