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.

  1. Select the files you want to add the header and/or footer to in the File Selector.
  2. Select a file format configuration such as “none” or “writable proprietary formats” that does not enable and read-only converters.
  3. Start with a fresh action.
  4. Set the action type to “search and replace”. Set the search type to “list of regular expressions”.
  5. In the Search box, enter the regular expression \A. This regular expression matches the position at the very start of the file.
  6. In the Replacement box, enter the header text you want to insert.
  7. Click the green plus button to the left of the Search box to add a second step to the action.
  8. Enter \z in the Search box to make the second step match at the very end of the file.
  9. Enter the footer text in the Replacement box.
  10. Set the target and backup file options as you like them.
  11. Click the Preview button to run a test.
  12. If all looks well, click the Replace button to actually add the header and footer.