@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 #### @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