查看: 301|回复: 0
打印 上一主题 下一主题

[教程] powergrep 001

[复制链接]

该用户从未签到

258

主题

1651

回帖

1万

积分

状元

Rank: 9Rank: 9Rank: 9

积分
19159

灌水大神章小蜜蜂章笑傲江湖章

跳转到指定楼层
1
发表于 2017-11-18 08:50:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Action Reference

The Action panel is the place where you define the task that PowerGREP will execute. The Action panel uses a dynamic user interface. Options that do not apply to the action you are defining will be invisible. This reduces clutter and confusion, and leaves more space to enter long lists of search terms. Since changing some of the options will make other options relevant or irrelevant, changing an option is likely to cause the Action panel to change its appearance.

All the options on the Action panel are arranged into nine parts. The parts are laid out from top to bottom in the order that PowerGREP uses them when you execute the action. Some parts are not available for certain action type. So when defining an action, start with selecting the action type at the top. Then work your way through the Action panel from top to bottom.

Action panel showing all nine parts

Action type: Tell PowerGREP what kind of action you want to execute: "simple search", "search", "collect data", "count matches", "list files", "file or folder name search", "file or folder name collect", "rename files or folders", "search and replace", "search and delete", "merge files", or "split files". Options that are specific to certain action types appear in this part when you select the action type. Some action types are more flexible than their names imply. The "list files" and "rename files and folders" action types, for example, can also copy files if you choose that target type.
Filter files: Prior to performing the actual action on a file, search through that file's contents to determine if this file should be processed or skipped. Since named capturing groups carry over from the filtering part to all following parts, you can also use the "filter files" feature to capture a part of the file's text to be used in the following parts of the action. The "filter files" part is available for all action types except "simple search".
File sectioning: You can make the main action search through only part of each file, or split up each file any way you want, rather than searching the whole file at once. A common choice is to process files line by line. Available for all action types except "rename files or folders".
Main action: The main part of the action is the set of search terms that perform the action you selected in the "action type" part. All action types have a main part. All action types except "list files", "file or folder name collect", and "merge files" require at l** one search term in the main part of the action. When you set the action type to "simple search", the main part of the action is the only part where you can enter search terms.
Extra processing: Only used for "collect data", "file or folder name collect", "search and replace", "rename files or folders", and actions. You can apply an extra search-and-replace to the replacement text or the text to be collected in the main action.
Context: PowerGREP can display extra context around each search match on the Results panel if you use the "context" part of the action to collect that context. Only used for actions types that display search matches found in the contents of files.
Between collected text: Specify whether search matches collected into target files should be delimited with certain text and whether the target files should have header or footer text. Only used for the "search", "collect data", "file or folder name collect", and "merge files" action types and only when "target file creation" is set to anything except "do not save results to file".
Target and backup files: Tell PowerGREP where it should save collected search matches, whether you want to modify the original files or create a new set of target files, or whether you want to copy, move, or delete the listed files. The available options depend **ly on the action type and can even change its apparent function. Selecting the "delete matching files" target type in combination with the "list files" action type, for example, essentially changes the action into a "delete files" operation. Only the "simple search" does not have any target options at all.
Comments: Enter a description of the action's purpose before adding it to a PowerGREP Library or saving it into an action file.
When you're done defining the action, use the Preview, Execute or Quick Execute items in the Action menu to execute it. The Preview item is the safest one, since it never modifies any files, or do anything else you might regret.

The buttons on the Action toolbar that correspond with the Execute and Quick Execute menu items change their labels to indicate exactly what will happen. The labels change whenever you change the action type or target type. When the action type is "rename files", for example, the word "Execute" changes into "Rename" or "Copy" depending on whether the target type is "rename files" or "copy files".

Discuss

Start or join the conversation on the topic "Docs: Action Reference" in PowerGREP's discussion forum.