Gossamer Forum
Home : General : Perl Programming :

Changing Headers on Multiple .html files

Quote Reply
Changing Headers on Multiple .html files
Now that I have LinksSQL up and running, I need to change the format of all my hardcoded pages to the format of the templates used by Links. I have over 2500 hardcoded .html files that I want to have the same header and footer. Is there an easy way to do this without manually changing each page. I normally use HomeSite to do my editing and they have a search and replace function, but it requires the search on multiple pages to be exactly the same before it will do the replacement. In these 2500 pages the current header and footer have slight differences based on hard coded html for the banner advertisements.
Bottom line:
Any way to automatically change all 2500 pages with a search and replace without manually changing each page?

</not a clue>
Quote Reply
Re: [Kilroy] Changing Headers on Multiple .html files In reply to
Easy if you have shell access...
find . -type f -iname '*.html' | xargs perl -p -i.bak -e 's|foo bar baz|some new text|'
this will recursively go through the directory you're currently in and do the replacement on *.html and also make a .bak backup of the file.

Quote Reply
Re: [brewt] Changing Headers on Multiple .html files In reply to
What I normally do with that kind of stuff if use activestate perl and write a script. really basic, just foreach read them in and replace.
account deleted