Skip to main content
Participating Frequently
September 16, 2022
Answered

Find and Replace on 1200+ HTML files

  • September 16, 2022
  • 4 replies
  • 578 views

I have a simple website that I need to change.  It has about 1200 or more HTML files.  For some reason internal links to other HTML files within the site (via a href) have an error.  I need to do a mass modification.

The html links are suppose to be /book_0001.html, /book_0002.html, etc, but for some reason are /book/0001.html, /book/0002.html, etc. Needless to say, the links do not work.  I want to change these back to but do not want to open every file, find every link and change it manually.  I have somewhat of a life 🙂  I have searched and tried the wildcards on some of the other post like ([^<]*) & [^"]* but either I am doing it wrong or just will not work.  Any help?

This topic has been closed for replies.
Correct answer Jon Fritz

Are there any links that need to stay /book/ ?

If not there shouldn't be any need for RegEx modifiers....

1. Make a backup of your site.
2. Hit Ctrl + Shift +F (or Find > Find and Replace in Files)
3. In the Basic tab, place /book/ in the Find field
4. Leave the In field as Entire Current Local Site and [any tag]
5. In the Replace field, add /book_
6. Hit Replace All

4 replies

B i r n o u
Legend
September 17, 2022

sometimes I need to have a concrete example to better understand what to do next...
could you , please, give me two different examples of bad URLs, and their respective desired corrections ?

Participating Frequently
September 17, 2022

It's solved now, thanks.

BenPleysier
Community Expert
Community Expert
September 17, 2022

Is it possible to supply the URL to the site so that we can see waht is going on?

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Participating Frequently
September 17, 2022

I am working on the fix.  The site is johnpwiles.com/johngill and when its fixed locally I'll upload and overwrite the current site.

BenPleysier
Community Expert
Community Expert
September 17, 2022

Oh, my goodness! John, I just read through Psalm 23 to get an idea of what you are doing. Great work, but extremely tedious.

 

Just a few comments about using frame sets (not to discourage you).

  • Not SEO friendly
  • Hard for screen readers to follow
  • Cannot be used for mobile devices

 

I look forward to seeing the final version.

 

 

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Nancy OShea
Community Expert
Community Expert
September 16, 2022

Before you go down this long  rabbit hole, do the links work on the actual server?   If it 'ain't broke, don't fix it.

 

Root root relative link paths typically work just fine on actual servers but fail when tested locally.    Some people actually prefer them.

 

If you use a local testing server, you can configure it to handle root relative links if you absolutely need to.

 

As to your bigger problem, nobody should be managing a 1200 page static website.  It's time to move to server-side tecchnologies with a database-driven site.  Among other things, changing sitewide links would require only a line or two of code.  Something to think about...

 

 

Nancy O'Shea— Product User & Community Expert
Participating Frequently
September 16, 2022

This is simple text pages and rather old.  I did test both local and on the server. I had to fix a bad link on all the sheets and did a find and replace on all the files.  Once I got this complete I found this error but it is not as simple as replacing www.websiteOLD.com with www.websiteNEW.com.  Now it's more complicated and looking for a simpler way.

Nancy OShea
Community Expert
Community Expert
September 17, 2022

How many links are you talking about?

How did the link paths get so messed up?

 

 

 

Nancy O'Shea— Product User & Community Expert
Jon Fritz
Community Expert
Jon FritzCommunity ExpertCorrect answer
Community Expert
September 16, 2022

Are there any links that need to stay /book/ ?

If not there shouldn't be any need for RegEx modifiers....

1. Make a backup of your site.
2. Hit Ctrl + Shift +F (or Find > Find and Replace in Files)
3. In the Basic tab, place /book/ in the Find field
4. Leave the In field as Entire Current Local Site and [any tag]
5. In the Replace field, add /book_
6. Hit Replace All

Participating Frequently
September 16, 2022

I can do this only partially.  The word "book" was just a filler.  It is actually 66 different book names. So I can work it off that end but was looking for a way to fix it on the number side. Thanks, I'll try this.