Welcome Forums General PowerShell Q&A Possible to automate insertion of header/footer to HTML file?

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

      I’m not asking anyone to do this for me, but want to know if automating this task is possible with PS before i waste too much time trying. 🙂

      I’m not a windows guy at all, and would normally just write this in PHP, but the place i work is Windows only, and they need a replacement for an antiquated .net routine and none of the crack “development” staff will attempt this simple task:

      Need to open a file from one folder, insert an HTML header and footer (i can find/replace a placeholder), then save the file to a new location.

      I’ve already determined that i can watch the origin folder for new saves, and trigger the copying of the file to a new destination.  If someone can tell me if it would be possible to insert a step to open the file, insert the header/footer, then save, i would appreciate it.

      Thank you.  As sick as this may sound, i’m actually looking forward to learning PowerShell 🙂

    • #168469
      Participant
      Topics: 21
      Replies: 38
      Points: 208
      Helping Hand
      Rank: Participant

      Yes, you can achieve the same easily. You have to save the file content in a variable, then use replace method to replace defined place holder, finally save/output the variable in a file.

      And also there are several ways to do it, the above mentioned way is not the ultimate option.

      Do some research, write your code, if you stuck, post back to us 😊.

      HTH

      Roy.

    • #168514
      Participant
      Topics: 1
      Replies: 1
      Points: 21
      Rank: Member

      Thank you for the prompt reply.  Happy to learn that there are multiple ways to accomplish this.  I’m on it!!!

Viewing 2 reply threads
  • The topic ‘Possible to automate insertion of header/footer to HTML file?’ is closed to new replies.