Replace content into multiple txts using a table from csv as data source

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 http://www.example.com/orange21.png blah blah blah http://www.example.com/orange21.png 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:

https://i.redd.it/95pzyxspe4e11.png

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

“blah blah blah http://www.example.com/oceansummer.mp4 blah blah blah http://www.example.com/oceansummer.mp4 blah blah blah.”

Is there anyscript that can help me?

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.

(Deleted)

(Deleted)

(Deleted)

https://gist.github.com/smphillips/791e5447423de322d56a2c8173ee93de