Dreamweaver: Mass Detach from Template
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:
- 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!
- Open BBEdit, and select Find from the Search menu. The Find & Replace dialog will appear. (click to enlarge)
- Check “Use Grep” When you do this, you will notice it colors the grep wildcard characters red.
- 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).
- Check the box for Multi-File Search, and Batch Find, then select select the folder on your local drive where the files reside.
- 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.
- repeat using
<!-- #BeginEditable.+? -->
- Now uncheck Use Grep because the next two are standard exact match searches (no wildcards needed)
then repeat the search and replace using
<!-- #EndEditable -->
<!-- #EndTemplate -->
That’s it – your files are now clean of template tags!