Hello,
My need is very basic and trivial: I'm on w10, and have to substitute a given string, name it string1, by an other, name it string2, in multiple files (with the same extension) in some given directory DIR. Obviously, I could use any text editor for that but in each files there is only one occurrence of string1, and moreover there are dozens of files in which the substitution has to be done, and I want obviously the substitution to be done in all the file at the same time.
So, I though to make a .bat file containing the following command:
But it doesn't work. Not string1 occurrence was replaced after I launched the .bat file.Code:powershell -Command "(gc C:\DIR\* .txt) -replace 'string1', 'string2' | Out-File -encoding ASCII C:\DIR\* .txt"
Nevertheless, when I precisely indicate the file (ie in using the command powershell -Command "(gc C:\DIR\file1 .txt) -replace 'string1', 'string2' | Out-File -encoding ASCII C:\DIR\file1 .text"), string1 is replaced by string2 in file1.text. But then I have to do that for each of my dozens of files, which doesn't fulfill my needs.
Surely 1337 c0d3r2 here will have a solution: how to perform the desired substitution in all the files at the same time???
Bookmarks