Author Posts

August 5, 2018 at 8:13 am

Hello everyone,

Basicaly all I need is a script to search for content inside multiple txts that matches column A in csv table. If we got a match replace it with content from column B and save the edited txt.

I write an example below
Inside orange21.txt for example there is a text like this :

"blah blah blah blah blah blah blah blah blah."

I have a csv table containing the links that lying inside those texts in column A. In column B I ve got the link I want to swap with.

My excel example:

After running the script my orange21.txt text should be like this

"blah blah blah blah blah blah blah blah blah."

Is there anyscript that can help me?

August 5, 2018 at 7:26 pm

If you're looking for prewritten scripts you should try it in the PowershellGallery or the Microsoft Technet Script library but I doubt you'll find something 100% suitable there. So you're up to write something for yourself.
Basically you'll need some nested loops with Foreach or Foreach-Object with some comparisons inside and some conditional string replacements inside. If your text file really looks like you showed above you shold be able to you Import-CSV instead of Get-Content and use the advantages of the csv object.

August 6, 2018 at 12:51 am