掌上百科 - PDAWIKI

 找回密码
 免费注册

QQ登录

只需一步,快速开始

查看: 795|回复: 0

[教程] powergrep 006

[复制链接]

该用户从未签到

发表于 2017-11-20 19:59:12 | 显示全部楼层 |阅读模式
actionfilter.html
7 A& _! x3 q) Y; \! U- T& V; N' `  P0 C) ]+ q
Action Part: Filter Files% ~' W; a$ E+ x' o- ^

# G$ n! j2 Z# W8 LFilter files
" G, ?% E1 L+ U
) z% J$ D8 v0 R0 t/ g8 N2 KThe "filter files" action part is available for all action types except "simple search". It enables you to use an extra set of search terms to filter out files. The "filter files" drop-down list gives you four choices:- S: h! u: s5 }  z) p
5 g  h$ J8 \& ^! J" Q3 A' j
Do not filter files: Process all files marked in the File Selector. All the other controls of the "filter files" action part are hidden when this option is selected.
4 m. l! X' L$ {, a0 DDisallow any terms to match: Process only files in which none of the file filtering search terms can be matched.' k+ e2 e. T& x" S
Require one term to match: Process only files in which at l** one of the file filtering search terms can be matched.
! |* e9 m" V1 S3 w+ O4 jRequire all terms to match: Process only files in which all of the file filtering search terms can be matched. The difference between the last two options only comes into play when filtering using a (delimited) list of multiple search terms.
) z' j6 L2 g1 P, R( V6 ?# \Filtering files is always done by searching through the contents of files. Even for "file or folder name search", "file or folder name collect", and "rename files or folders" actions where the main part of the action searches through the file's name. If you want to filter out files based on their file names, use the "exclude files" box on the File Selector panel.$ j3 s3 D# J: b/ A$ V# Z0 h

* E4 ?4 x# h7 N3 j$ hThere are no options to specify other than the search terms you want to filter with. Matches found by the "filter files" action part never show up on the Results panel. If a file is filtered out, it is indicated in the results as not having any search matches, regardless of whether it was filtered with "disallow any terms to match" or "require one/all terms to match". If a file is not filtered out, the results show its search matches as usual, if any are found by the main part of the action.4 a( {. j6 T7 _8 m

1 ~) \* d# i2 T5 u  aA And Not B
) Q$ J9 p7 Y/ {1 @
5 b# G3 q) v0 T" j# E, @$ BA and not B
* z4 j" y* w2 d: b; `* w0 _; M4 v0 }
To get a list of files that contain "A" but not "B", set the "action type" to "list files". Specify A as the search term in the main part of the action. Set "filter files" to "disallow any terms to match" and specify B as the search term to filter with.* A( W1 W/ a. |# d% G! {" F
( Y! @- l8 _- D! k$ @
If you do this with the "search" action type, you'll get a list of all the occurrences of A in all the files that do not contain B.( C8 Z; h$ ]  W4 ]3 B

$ e, R9 {& P6 |$ s. z* ?Example: Boolean operators “and” and “or”- A" T  ^! N6 X, ]$ M1 P

& c0 z' |0 V. K$ dCapture Text for Reuse+ U" o3 \, M) Y5 O  q

3 i* g- u: r  ~/ hRename Files Based on HTML Title Tags9 r$ s( u  F0 Q- N: k5 M

0 G- h1 ^6 w- D# kWhen using regular expressions, named capturing groups carry over from the "filter files" part of the action to all the other parts. This means you can use the "filter files" part to run an extra search to capture a part of the file. The filter doesn't necessarily have to exclude any files. You can then search for that part elsewhere in the file by using a backreference to that named capturing group in the regular expression in the main part of the action. Or you can insert that part somewhere by using a backreference in the replacement string in the main part of the action.
& M; A- ~" @' z6 r5 j4 _% T' B. E) Z! T2 N
You can even capture multiple parts of the file by using a list of regular expressions with a differently named capturing group in each regular expression. Set "filter files" to "require all terms to match" and turn off "non-overlapping search". These two settings ensure PowerGREP searches through the entire file once using each regular expression in your list, filling the named capturing group(s) of each regular expression, provided they can all find a match in the file.
0 @# G: n) f; v/ D" V. r
3 Y* b5 \1 @) y, Y/ p/ Q& ]Named capturing groups also carry over when "filter files" works on the contents of files (which it always does) and the main part of the action works on file names (which it does for "file or folder name search", "file or folder name collect", and "rename files or folders" actions). This allows you to search through the file's name for something found in the file's contents, or collect part of the file's name along with part of the file's contents, or change the file's name to something found in its contents. The screen shot shows an example of using this technique to rename HTML files to their titles or top-level headers.
6 l# }- |  G; s7 q6 V7 \* I3 c3 T' [/ L" W
Examples: Rename Audio Files Using Meta Data, Insert proper HTML title tags and Rename files based on HTML title tags/ B: ?; d* y& y( c% O7 \. R9 Z- a

$ u. j1 \4 A1 T; E0 E  g% wDiscuss
8 t6 J0 Z1 ^( P! u, F; O. j: Y8 w" ~& E. J) h& ~
Start or join the conversation on the topic "Docs: Action Part: Filter Files" in PowerGREP's discussion forum.
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

小黑屋|手机版|Archiver|PDAWIKI |网站地图

GMT+8, 2024-3-29 04:47 , Processed in 0.026340 second(s), 8 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表