Are There Any macros that can substitute one block of code for another, in multiple webpages

I need to make the same code change to approximately 75 webpages. There are 2 changes I need to make to each page. Although different, each change involves a "replace this block of code" with a different block of code.

Before hiring a subcontractor to manually do this, I'm wondering if there is any macro software available that can accomplish this? It would need to be fairly simple to set up because, except for a few isolated HTML commands, I really don't know how to program.

I know that there are numerous free as well as commercial macro software programs out there, but I have never used any.

Thanks for your help.
photoman11Asked:
Who is Participating?
 
scrathcyboyConnect With a Mentor Commented:
Can you identify the code block to be replaced by a unique starting tag or word and a unique ending?

And is the code to be replaced available in a separate file?  Does each HTML file get the same code replacement.  IF you can be a bit more specific, we can narrow it down.
0
 
Tyler LaczkoConnect With a Mentor Commented:
You can use wordpad, its built into windows, and do a find / replace for the code.
0
 
photoman11Author Commented:
scrathcyboy,

I have attached the HTML file of a representative page. The page is visible at http://www.best-family-photography-tips.com/EE-test.html.

If you open up the file in an editor, the first block of comments which explains what I want deleted and added, is at line #124. The 2nd block of code is at line #293.

The same code to be replaced is on every page, although not at the same line number as in this page. The blocks of code used as the replacement code, is identical for all pages also.


professionalc…

Thank you. Find and replace would certainly work, but still require a lot of manual intervention. What am hoping to find is some way to automate the process to avoid the manual work.
EE-test.html
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
scrathcyboyCommented:
I looked at the code, and no, I don't see any easy or safe way to automate the 2 replacements -- any macro would depend on your HTML editor, and if you missed one tag, it would foul up all the pages very nicely for you.  Drop me an email if you want help.

I did see one problem though, which you might want to field before you do these replacements.  The INCLUDE file is a SHTML, and I think you will have trouble including a secure HTML page in a non-Secure HTML page.  Does the extension have to be SHTML?  As I recall, both the web server and most browsers will choke on this type of cross-security include.
0
 
photoman11Author Commented:
scrathcyboy,

Thanks. No problem about the SHTML include - it is my hosting service that insists upon this approach.

Confused about comments that macro seems dangerous, but to drop you an email if want help. Help in a way other than we're discussing?? Please explain.
0
 
scrathcyboyCommented:
For a macro to work, you have to have a start point and an end point of specific text (or in the case of HTML, code).  Now if that end-point code is missing in a page, or duplicated within the macro area to be replaced, then only part of it will be replaced -- and possibly in all your documents.  Now you have a mess because the code was not completely replaced, so you spend more time fixing it than you would have doing it by hand in the first place.
0
 
photoman11Author Commented:
Got it. Thank you.

By the way, do you recommend any macros for things in general, which do not require heavy programming abilities?
0
 
scrathcyboyCommented:
Macros depend on the software you are using.  MS Word continued the tradition of Wordperfect to provide recordable macros for repeated steps in editing word documents.  Making them takes a bit of practice, they are intimidating at first.  But they can be real time savers.

The question of "parsing HTML" code has cropped up here repeatedly on EE, and it is far more fearsome than editing a document.  Browsers are often forgiving -- if you forget to end a form or table with the closing tag, they will render the form or table anyway.  

But in PARSING the HTML -- i.e. going through it and blocking out all the code that exists in a FORM, for example -- if the person put the closing </FORM> tag, then everything is OK.  What happens if they forgot it?  Then instead of parsing the HTML to remove the FORM only, you end up deleting the entire document after the start of the FORM tag, because no end tag was ever found.

That is probably why I have never seen a program to go through HTML code (i.e. parse it) and cut out whole blocks of code and replace with other blocks of code.  You can get macros to change case or search just in a single tag, but the risk of balancing all tags is too great for mass search replace.

So when you do a google search for this -- macro to search replace HTML
almost all you get is discussions of WORD macros and EXCEL macros !!!
TRY IT !!

But neither Word nor Excel are HTML editors.  Therefore you have to find an HTML editor that has macro capability on the HTML code itself (not the finished page) to correctly search and replace the code, and neither do it.  Check your own HTML editor to see if it has Macro features.  IF so, try them.

0
 
photoman11Author Commented:
thanks for your advice.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.