Find String from Multiple Files and Replace It Without Creating New File

Find String from Multiple Files and Replace It Without Creating New File

I want to find string e.g. "date" from my files of a folder which contains multiple ".c" and ".h" files in it and replace it with "date 24-April-2018" using batch file. what should do? Please see below code. I want to do the same but not for one file Input.txt , I want to do for multiple files with extensions of a folder

@echo off 
setlocal enableextensions disabledelayedexpansion

set "search=@date"
set "replace=@date 24-apr-2018"

set "textFile=Input.txt"

for /f "delims=" %%i in ('type "%textFile%" ^& break ^> "%textFile%" ') do (
    set "line=%%i"
    setlocal enabledelayedexpansion
    >>"%textFile%" echo(!line:%search%=%replace%!
    endlocal
)
4
Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.