Scripts – Expression Evaluator & Replacement Prompts

Advanced Script Settings and the Expression Evaluator are designed to used for scripts run via batch files using command line switches. The advanced script functions are geared toward complex operators that are run with replacement prompts turned off for the script via the Options button on the Advanced Script Settings dialog.

It is OK to use Replacement Prompts during advanced operations. However, you should note that the behavior of replacement prompts during search & replace operations involving complex expressions differs from those using a standard OR expression such as E1 OR E2.

When making replacements the Expression Evaluator is applied after all the search hits and ‘replacement opportunities’ for the entire operation are accumulated. Please keep the following in mind when making replacements and/or testing your expressions:

First, when replacement prompts are on, prompts are offered for search hits in every file meeting the file mask, path, and filter criteria, even though only some of those files might satisfy the criteria in the Expression Evaluator. Responding affirmatively to replacement confirmations in files that do not satisfy the expression will have no effect on those files. Regardless of how you respond to replacement confirmation prompts, replacements take place only in files that actually satisfy the expression!

Second, if you have replacement prompts enabled and respond “Skip” to a replacement that initially satisfies your expression, the “Skip” may influence the result of your expression. Number values in expressions are based on the number of search & replace opportunities in a file. Since a “Skip” eliminates one replacement opportunity, “Skip(s)” may impact expressions that make use of number values. For example, given the expression (E1 >= 2) and a file having exactly 2 search & replace opportunities. A manual “Skip” in response to either of the replacement prompts eliminates 1 search & replace opportunity. The file would therefore no longer satisfy the expression (E1 >= 2). This in turn means that no replacements would be made, even if you respond “Replace This” to the other prompt.

In some cases you may wish to enable replacement prompts in order to capitalize on the above behavior as this provides a way to have ‘on the fly’ control over your expressions.

Regarding debugging expressions, you should note that search-only operations report hits only in files that actually satisfy the expression. Therefore, to debug your script in advance of a search & replace operation and identify the specific files that will be selected by your expression, run a search-only operation. Another debugging tactic is to intentionally run a search & replace operation with confirmations set to “Prompt on all”. This allows you to see all search/replace strings in-context in all files.

The table below outlines these characteristics:


Given the following:



Contents of File #1:

Page 12


Contents of File #2:



Script Search Strings:

E1 = 12
E2 = Funduc


Expression Evaluator:


Results of the following scenarios would be:






The strings “12” and “funduc” would be reported in File #2 only.


Unprompted Search & Replace:

Replacements would be made in File #2 only.


Prompted Search & Replace:
(Where user selects “Replace This” in each instance)

You would be prompted to replace the “12” in File #1 and12” & “funduc” in File #2. Even if you answer “Replace This” to the “12” in File #1, File #1 would not be modified because it does not satisfy the Expression, (E1 AND E2). File #2 would be modified because you allowed all replacements to occur in File #2.


Prompted Search & Replace:
(Where user selects “Skip” to either of the prompts for File #2)

No replacements would occur in File #1 (as above). No replacements would occur in File #2 because a skip in response to either prompt for File #2 means it no longer satisfies the expression (E1 AND E2).

Expression Evaluator & Replacement Prompts