Note: A Replace operation can be applied only to text files. If a binary file is encountered, the script might fail with a macro error.
Find Or Replace Finds (that is, counts) or replaces particular words or phrases in files. It can also handle special characters such as tabs and line feeds.
Input Parameters
FindOrReplace_Find (Required) - Specifies a value to find.
FindOrReplace_Replace - Specifies a value to replace. (Ignored if Action is "Find".)
FindOrReplace_Action (Required) - Specifies whether to just find (and count) instances or replace them as well.
FindOrReplace_CaseSensitive (Required) - Specifies whether comparisons are case sensitive or not.
FindOrReplace_SkipFileSizeMB - If a file is larger than this (MB) and if special characters are being used, then skip that file. The default is 100; maximum value is 500 (500MB).
Output Parameters
FindOrReplace_Count - Returns the number of times the Find value appeared in this file.
FindOrReplace_CountTask - Returns the number of times the Find value appeared in all files encountered during this task run.
Special Characters
FindOrReplace can handle special character operations such replacing all tabs with three spaces or stripping carriage returns from a file. To work with special characters, represent those characters by using special character macros in your FindOrReplace_Find or FindOrReplace_Replace parameters as appropriate.
The following special character macros are supported.
[char_cr] - Carriage return (ASCII 13)
[char_lf] - Line feed (ASCII 10)
[char_crlf] - Carriage return followed by a line feed (ASCII 13+10)
[char_tab] - Tab (ASCII 9)
[char_ff] - Form feed (ASCII 12)
[char_null] - Null (ASCII 0)
[char_###] - ASCII code ###
For example, to:
...replace tabs with three spaces, configure:
FindOrReplace_Find = "[char_tab]"
FindOrReplace_Replace = " "
...strip line feeds, configure:
FindOrReplace_Find = "[char_lf]"
FindOrReplace_Replace = ""
...add a carriage return to the end of each line feed, configure:
FindOrReplace_Find = "[char_lf]"
FindOrReplace_Replace = "[char_crlf]"
...replace "doAg" with "BonE", configure:
FindOrReplace_Find = "do[char_65]g"
FindOrReplace_Replace = "[char_66]on[char_69]"
Notes
Use the replace operation only against text files. Do not use to replace text in a binary file; this could have unforeseen consequences.
You can run this built-in script only one time per file.
This script cannot be run as the first step in a task.
Example #1
Ed wants email that lists the number of times that the word "- PAGE" appears in files that pass through MOVEit Automation.
To perform this operation with MOVEit Automation:
Create a new task with a source, process, destination, schedule and next action.
Select "Find Or Replace" as the process
Set process parameters:
FindOrReplace_Action = "Find"
FindOrReplace_Find = "- PAGE"
FindOrReplace_CaseSensitive = "Yes"
Configure the next action to:
Send an email with the macro "[Parm:FindOrReplace_Count]" in the message body.
Run per-file (not per-task).
Example #2
Jane wants to replace all instances of "bubbler" with "drinking fountain" in files that pass through MOVEit Automation.
To perform this operation with MOVEit Automation:
Create a new task with a source, process, destination and schedule.