Find and replace between 2 text documents

Welcome Forums General PowerShell Q&A Find and replace between 2 text documents

Viewing 2 reply threads
  • Author
    Posts
    • #192826
      Participant
      Topics: 1
      Replies: 1
      Points: 14
      Rank: Member

      Hi

      First of I don’t know anything about PowerShell, but I think it might be the way to solve my problem.

      I have 2 text documents, where I have a lot of text to copy from doc A into doc B – but it is full of variables.
      What I need is a way to say: in doc A, find Variable – then copy the first instance of text (similar to) ” Line”words here” ” Move to doc B, find same Variable and replace ” Line”” ” with text from doc A.

      The Variable is a ID number to match the text, so it will keep changing (ID0001, ID0002 and so on) .

      Any guidance is appreciated.

    • #192904
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      First of I don’t know anything about PowerShell, ….

      Any guidance is appreciated.

      You might start with learning the very basics of Powershell. Without that you probably wouldn’t understand the help you get in forums like this one. There are a lot of good sources to start with … some of them free of charge https://powershell.org/free-resources/ … some of them not but worth the money … https://www.amazon.com/s?k=Powershell+book&ref=nb_sb_noss . … and some them even free and entertaining … https://channel9.msdn.com/Series/GetStartedPowerShell3

      Good luck and have a lot of fun!

      • #192985
        Participant
        Topics: 1
        Replies: 1
        Points: 14
        Rank: Member

        Hi Olaf – Thank you. I guess a better definition is I know enough to be dangerous?
        I run commands I am familiar with and have a few on scheduled tasks, but writing from scratch is outside my comfort zone.

    • #192997
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      I still think you’d be better of by starting with

      … I know enough to be dangerous?

      … but writing from scratch is outside my comfort zone.

      Two reasons more for starting with the basics of Powershell. 😉 Another great free source for beginners: Windows-PowerShell TFM 4

      Regardless of all that – it will be hard to recommend something meaningful without to know many more details of your task … some example data of your text documents and the relation between the pieces of text you want change.

      Probably you will need some of the following cmdlets and statements: Get-Content, Foreach-Object, Select-Object, about_if, about_comparison_operators.
      You should always read the complete help including the examples to learn how to use it.

Viewing 2 reply threads
  • The topic ‘Find and replace between 2 text documents’ is closed to new replies.