HandyFile Find And Replace: Text Workbench Online Help Submit feedback on this topic   

Collector Tab

Using The Collector
Tab Fields
Collector file modes
    Single File
    Individual file for each processed file
    Individual file for each match


This page allows you to store the found text (or the text you want to replace the found text with) in an arbitrary file. Such collector function allows to:

If you do not need special expert features, you can use the Single File collector mode.

Using The Collector

Follow the steps below to gather text from files and store it in a collector file. This sequence presumes the use of Single File mode.

  1. Specify the search location, file mask(s), text to find (and optionally to replace - this mostly applies to regular expressions) as usually.
  2. On the Collector tab, check the box Collect...
  3. Specify the collector file path and name.
  4. If you want to create a new collector file, select the Overwrite file mode. Otherwise, select the Append mode.
  5. Set what kind of text you want to collect - Found text of Replacement text. Choosing the Replacement text option allows you to alter the found text in any way, even if you do not perform the actual replace.
  6. Choose the kind of separator to insert between each added text entry.
  7. Click the Search button (or Replace if you need to simultaneously perform the replace operation).

Tab Fields

The tables below describes the tab fields.

General Options

Field Description
Collect the found text using the following rules If checked, creates (or reuses) the collector file and stores the text in it.
If unchecked, no collecting occurs.
Allow collector when performing a scenario If this options checked, the collector function is allowed if you are performing one of the scenarios.

Collector file

Field Description
File to store the collected text Path and name of the file to collect the text. If the file and/or path do not exist, they will be created. Path and file format depends on the current splitting mode.
  • Single file mode does not allow special tags. You have to specify the file path and name in common format.
  • Individual file for each processed file mode allows the use of tags <F:n>, which are used to insert tagged parts of the current File name if regular expressions are used as the file filter. If you do not use regular expressions in your file filter, you can use tag <F:0> to insert the whole file name.
  • Individual file for each match mode allows the use of tags <F:n> just in the same way as for the previous mode, plus tags <M:n>. These tags insert the contents of the stored expressions (Matches) obtained when processing a file. You define stored expressions in the Find What field of the Files and Text tab. Regular expressions option must be turned on to use tags <M:n>.
See Remarks below for detailed description of the collector file modes. The collector file is always created in the ANSI format, regardless of the processed file nature.

Tags are case-insensitive. This means that <F:n> is equivalent to <f:n> and <M:n> is equivalent to <m:n>.
 Browse for file button
Click this button to locate and select the file to store the collected text.
 Open file button
Clicking this button will display a menu with the following commands:
  • Open File - opens the file using the associated application.
  • Open File Folder - opens the Windows Explorer and locates the file in its right pane.
Splitting mode button Click this button to set the mode of the collector file creation. See Remarks below for detailed description of the collector file modes.
Insert tag button Click this button to insert a tag of one of the two allowed types: <F:n> or <M:n>. This button is the shortcut to inserting these tags.

Existing file mode

Field Description
Overwrite Select this option to replace the data in the existing file with the new contents. In the file does not exist, it will be created.
Append Select this option to append the collected data to the file contents. In the file does not exist, it will be created.

Collected text

Field Description
Found text If selected, the found text is stored in the collector file.
Replacement text (also when searching) If selected, the text that you've specified in the Replace With field is stored in the collector file.

You can store the replacement text even if simply searching files for text. This option is generally useful for searches with Regular Expressions, as it allows you to alter the found text in any aspect.

Text entry separator

Field Description
None The text is collected as-is, no additional data is written to a file.
New line Finalizes each write operation to a collector file with a CR+LF pair, CR or LF.
Other symbol or string Allows to insert arbitrary text between each write. Useful for creating CSV files.

Remarks: Collector file modes

There are three collector file modes, varying in both complexity and capability. 

Single File

This is the simplest mode. The single file mode stores all the found data in a single file, path and name provided. You can use this mode, for example, to collect any information from your files. For example, you can collect e-mail addresses from multiple pages and store them in a single file.

Example

To store all e-mail addresses form your HTML pages, select the Single File mode, specify path to the collector file (e.g. C:\myweb\emails.csv), type the regular expression in the Files and Text tab to describe the e-mail pattern (e.g. [\w\.\_\d]+\@[\w\.\_\d]+\.\w+), set the Collected text option to Found text, Text entry separator to New line and click Search.

Individual file for each processed file

This mode creates a new collector file every time a new found file is started to process. This allows you to separate the found text and distribute it to individual files.

File name creation: "Individual file for each processed file" mode

If you need separate files for each processed file, you would have to define a special rule to form a collector file name and/or path. The HFFR offers you a special tag to define parts of the collector file name and/or path. The tag has the following format: <F:n>. This tag inserts the contents of the stored expression used in the file filter expression, numbered by n. To insert the while name of the currently processed file, you can set n to 0.

Example

If you define the following file filter: (get\w+)\.html and specify the following collector file pattern:

C:\result\file_<F:1>\file.<F:0>.result.txt,

the collector will create a file

C:\result\file_getID\file.getID.html.result.txt

when the HFFR starts to process file getID.html.

Individual file for each match

This is the most powerful though the most complicated mode. This mode creates a new collector file every time a new occurrence of the matching text is found. This allows you to create individual files for each found text fragment.

File name creation: "Individual file for each match" mode

To define a pattern for collector files, you can use tags <F:n> as with the Individual file for each processed file mode as well as tags <M:n>. This tag is equivalent to the regular expression operators \n used in replace pattern. This tag inserts the contents of the stored expression numbered by n. To insert the whole found text in the file path or name, you can set n to 0. You define stored expressions in the Find What field of the Files and Text tab. Regular expressions option must be turned on to use tags <M:n>

Example

If you define the following file filter: (\w+)\.cpp and specify the following search expression in the Files and Text tab that would match a C++ class method definition:

{[\_\w\d]+}?\s*(C[\w\d]+)\:\:([\_\w\d]+)

and specify the following collector file pattern:

C:\myclassdoc\class<M:1>\<M:1>.<M.2>.<F:1>.txt

the collector will create a file

C:\myclassdoc\classCMyList\CMyList.AddTail.MyList.txt

when the HFFR processes file MyList.html and finds the method CMyList::AddTail.