There are times when you may find it necessary to detach hundreds of pages from their Dreamweaver templates. Unfortunately, within the Dreamweaver interface the only way to detach multiple files from their templates is to open each one, then select “Modify:Templates:Detach from Template” from the menu.

A better way to go is to use a simple “grep” search in BBEdit:

  1. Make sure you have a backup of your site. You can cause truly spectacular destruction with mass search and replace! OK, you’ve been warned!
  2. Open BBEdit, and select Find from the Search menu. The Find & Replace dialog will appear. (click to enlarge)

  3. Check “Use Grep” When you do this, you will notice it colors the grep wildcard characters red.
  4. paste this text into the Find box:
    <!-- #BeginTemplate.+? -->  

    Leave the Replace With box blank (you want to replace the Begin Template tag with a blank).

  5. Check the box for Multi-File Search, and Batch Find, then select select the folder on your local drive where the files reside.
  6. Click “Replace All.” If you are the cautious type, and want to test it first, just click “Find” a couple of times, so that it will find the first result or two, and make sure it is highlighting the right tags.
  7. repeat using
    <!-- #BeginEditable.+? -->
  8. Now uncheck Use Grep because the next two are standard exact match searches (no wildcards needed)
  9. then repeat the search and replace using

    <!-- #EndEditable -->

    and then

    <!-- #EndTemplate -->

    That’s it – your files are now clean of template tags!