|I currently have a batch file that chacks the contents of a file and replaces part of a text string (thanks to Machanix2Go)this works fine.|
However, now I need to run this script on all files in a directory (different file names and file extensions)and it is important that I keep exactly the same file name and extension.
The script is as follows:
@ECHO OFF > d:\l\var\pmcli\ifc\CCS\jobs\tempfile & setLocal EnableDelayedExpansion
ECHO **CHANGING EXP CODE** >> d:\l\local\LogFiles\OldJobOut.log
FOR /f "tokens=* delims=" %%a in (d:\l\var\pmcli\ifc\CCS\jobs\bjobo) do (set str=%%a
IF !str:~18^,2! equ 20 (
ECHO !new! >> d:\l\var\pmcli\ifc\CCS\jobs\tempfile
SET /a chgs+=1) else (echo !str! >> d:\l\var\pmcli\ifc\CCS\jobs\tempfile))
ECHO **EXP CODE NOW "SCDC1234567890"** >> d:\l\local\LogFiles\OldJobOut.log
As you see a temporary file is created but I cannot figure out a way to rename it as the original or run it on every file in the directory.
Thanks in advance for any help