[Solved] change word inside multi TXT and save same name [duplicate]


Without utilising another tool/language, batch file solutions will generally write a new destination file before deleting the target file and performing a rename.

Here therefore is an option utilising the built-in PowerShell scripting language:


From a batch file, with the text files in the current working directory:

@PowerShell -NoLogo -NoProfile -Command "Get-ChildItem '.\*.txt'|%%{(Get-Content $_.FullName) -CReplace 'EDI','INO'|Set-Content $_.FullName}"

From the Command prompt, with the text files in the current working directory:

PowerShell -NoL -NoP "GCI '.\*.txt'|%{(GC $_.FullName) -CReplace 'EDI','INO'|SC $_.FullName}"

If both cases, if you wish for the search string to be case insensitive, change -CReplace to -Replace

6

solved change word inside multi TXT and save same name [duplicate]