Possible to automate insertion of header/footer to HTML file?

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

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
1 month, 2 weeks ago.

  • 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: 20
    Replies: 32
    Points: 160
    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!!!

You must be logged in to reply to this topic.