Define a Search Action

1. Start with selecting the kind of action you want to execute in the "action type" drop-down list in the upper left corner of the Action panel. As soon as you do so, the Action panel will rearrange itself slightly. Not all options are available for all action types.

2. Select the kind of search term you want to use from the "search type" list. Again, the Action panel will rearrange itself so you can enter that kind of search term. PowerGREP supports four kinds of search terms, which you can enter in three ways:

3. Toggle search options:

4. When the action type is "search" or "collect data", specify how matches should be collected.

5. If you want to exclude some files from the action based on their contents, use the "filter files" option. An additional set of controls for entering search terms will appear.

6. Select a file sectioning option if you don't want to search through entire files. An additional set of controls for entering search terms will appear. Select the "split along delimiters" sectioning type to make the main action (steps 1 through 4 above) process only those parts of each file between the matches of the sectioning search terms. Select "search for sections" to make the main action process the matches of the sectioning search terms. To really make use of "search for sections", the sectioning search term should be a regular expression.

7. When sectioning a file, additional options affecting the main action (steps 1 through 4 above) are available.

8. Turn on "extra processing" if you want to apply an extra search-and-replace to the replacement text in a search-and-replace action, or the text to be collected in a "collect data" action. When you do so, an extra set of controls for entering search terms will appear. This second search-and-replace will be executed on the replacement text or on the text to be collected, each time the main search finds a match.

9. If you plan to study the search results on the Results panel in PowerGREP, you can make things easier by collecting extra context before and/or after the match. Context is only used for display purposes on the Results panel.

10. Specify target file options. If the action type is "list files", "file or folder name search", or "file or folder name collect", PowerGREP can save the file names of the files that are found into a target file. If the action type is "search and replace" or "search and delete", the target settings determine if the replacements are made in the files being searched through, or in copies of those files. When the action type is "collect data", PowerGREP saves search matches or collected text to into either a single target file for the whole action, or into one file for each file searched through.

11. When creating target files, set the backup file options to make sure backup copies are made when files are overwritten. Backup copies are required to be able to undo action in the Undo History.

12. To test the action, click the Preview button in the Action toolbar. PowerGREP will execute the search without creating or overwriting any files, or doing anything else you might regret. Click the Execute button to execute the action for real. Click the Quick Execute button to save time when you don't need full details of the search results.

When PowerGREP finishes running the search, a full report appears on the Results panel. Unless you used the Quick Execute button, the results are highly detailed.

If you want to add the action to a library or save it into an action file, enter a description of the action in the Comments field to help you remember the purpose of the action.