Add a Header and Footer to Files
With a search-and-replace action, you can just as easily insert new information into files as you can replace information. The difference is that rather than specifying a search term to be replaced, you use a regular expression that matches a position in the file. Anchor and lookaround tokens are two ways of matching a position rather than actual text with a regular expression. Another way is to simply use the backreference \0 to reinsert the search match into the replacement text.
This example uses the anchor method. The navigation bar example uses the backreference method.
- Select the files you want to add the header and/or footer to in the File Selector.
- Select a file format configuration such as “none” or “writable proprietary formats” that does not enable and read-only converters.
- Start with a fresh action.
- Set the action type to “search and replace”. Set the search type to “list of regular expressions”.
- In the Search box, enter the regular expression \A. This regular expression matches the position at the very start of the file.
- In the Replacement box, enter the header text you want to insert.
- Click the green plus button to the left of the Search box to add a second step to the action.
- Enter \z in the Search box to make the second step match at the very end of the file.
- Enter the footer text in the Replacement box.
- Set the target and backup file options as you like them.
- Click the Preview button to run a test.
- If all looks well, click the Replace button to actually add the header and footer.