Batch file to change some text.

April 24, 2009 at 10:20:14
Specs: Windows XP
Hi guys i would like to create a batch file to change the date in multiple text files but am kind of lost, here is what i have:

set SrcFolder=c:\test
set DstFolder=C:\test1

for %%a in ("%SrcFolder%\*.txt") do (

(for /f "usebackq delims=" %%h in ("%%a") do (
if "%%h" equ "SYS CONFIG 20090427" (echo SYS CONFIG DONE) else (echo.%%h)

something is wrong cause it does not work, any one help me out or even write me a new one cause i took the text from one someone else made for me but i dont want to enter additional text i want to edit the date out and replace it with the date i want.

See More: Batch file to change some text.

Report •

April 24, 2009 at 13:03:17
@echo off
set SrcFolder=C:\test
set DstFolder=C:\test1

pushd "%SrcFolder%"
for %%a in (*.txt) do (
  for /F "delims=" %%h in ('type "%%a"') do (
     if "%%h"=="SYS CONFIG 20090427" (
       echo.SYS CONFIG DONE >> "%DstFolder%\%%a"
     ) else (
       echo.%%h >> "%DstFolder%\%%a"

The above script however finds the selected string if just at the beginning of each line. To replace no matter the position is easier but yor knowledge about NT batch scripting looks weak from your post.

Report •
Related Solutions

Ask Question