Scripts – Format of Script Files
Scripts are saved as ASCII files. The safest way to create a valid script is to use the Script dialog. As you gain experience you can modify/create scripts with your text editor, perhaps using an existing script as a model. Be sure to reload your script into the Script dialog if you edit it with an external editor.
A text counterpart to this section is installed with the program. The file name is ‘ScriptInfo.txt‘. Sample scripts are also installed with the program. The sample scripts end with the name extension, ‘.srs’.
The simplest script possible is a text file consisting of a search string(s) separated by blank lines or a search/replace string(s) on adjacent lines. See Simple Script for more information.
If you are running a script from the command line, add the /s switch to launch Search and Replace and automatically initiate a search. If your script involves a replace, use /r in your command line to initiate the replace.
Please note that if you specify linked script(s), follow-up scripts operate in the same mode as the script that launches them. For example, if the initial script is run as a search-only, scripts linked from the initial script are also search-only. If the initial script is run as a search-replace, linked scripts are search-replace.
Please scroll this screen to see other notes on script syntax.
[Script for Search and Replace]
This is an example script using alternate program options for the
script. The text you are reading here is the script comment added
via the Advanced Script Dialog.
NOTE: The script sections demarked by [ ] and the [Options]
switches must be entered in the order you see here. The first
line must be the bracketed ‘Script for Search and Replace’ tag
above. If you are not using Linked Scripts, the ‘End of Search
and Replace Script’ tag is the last line.
NOTE: It is not necessary to specify all the [Options] switches.
For version 3.9 and above, switches within the [Options]
section can be in any order. If a given Options switch is not
specified in a script, the settings last in effect for the
program will be used. In addition, the General Options settings
that are included in the ‘SRDUMP file’ method above are ignored
when the script is run in version 3.9+. For example, if your
script specifies a ‘Default Viewer’, the program ignores this
when you run the script. This preserves your default settings
for interactive use.
NOTE: Use the ‘SRDUMP file‘ method to generate a script
that contains the program options currently in effect. You can
use SRDUMP.SRS as a template for developing other scripts
NOTE: The iteration switch, Script Loop= , must be added by editing
the script manually with your text editor.
Script Loop= must be the last entry in the [Options] section.
See F1 hlp topic – Scripts – Iteration Operator – for more info.
NOTE: See F1 hlp topic – Scripts – Linked Scripts – for information
on how to chain scripts. For version 3.4, follow-up scripts are
specified below the [End of Search and Replace Script] line in
a script. You must specify this manually, via your text editor.
E1 AND E2
Count Across Files=0
Process Binary Files=1
Num Buffers To Process=0
Append to output file=0
Write to Backup Dir=0
Keep file time stamp=0
Max Display Chars=128
Max Reg Expr=32767
Show Progress Dialog=1
Line Prefix=Line %3d -
Binary Prefix=Offset 0x%6lx -
Show Files Without Hits=1
Display Replace String=1
Display File Stats=1
Show File Date and Size=0
Min Size Filter=0
Max Size Filter=0
Min Date Filter=%%today-1%%
Max Date Filter=
Skip Files Mask=0
Sort File Names=3
[Search] This comment added to a search line.
Search string #1
[Replace /b] This comment added to a replace line.
Replacement string #1
[Search /bix] See / switches for more info.
Search string #2
Replacement string #2
[End of Search and Replace Script]
See ‘SRDUMP file‘ for instructions on generating a script consisting of the current settings for the program. You can use that file as a template for other scripts.
The following tags must be at the beginning and end of the script: [Script for Search and Replace] and [End of Search and Replace Script].
Comment text must immediately follow the [Script for Searc
h and Replace] section or after the closing ] bracket in the Search &/or Replace strings.
The order of section headings must follow that outlined above.
The [Options] section is not required. If you create a script using a text editor and wish to set only one or a few options, it is OK to enter only those specific options. Scripts saved via Search and Replace will have all options saved with the script.
Search strings can be entered on the next line after a [Search] tag. To enter the Regular Expression, Case Sensitive off (or Insensitive), Whole Word Only and Binary Mode, you must use the /x /i /w /b flags respectively. The flags are case insensitive. This is similar to the flags for Command Line Parameters.
Replace strings can be entered on the next line after a [Replace] tag. You can only use the /b flag for Binary Mode with this tag since all other tags are specified on the Search field.
Path and mask strings can be entered on the next line after a [Path] tag. No flags can be used with this tag. The mask string must be entered right after the path string and a \ character is expected between them. For example c:\*.ini will use Path C:\ and Mask *.ini. If you turn on the Search Subdirectories box on the main window, all INI files on the C: drive would be processed.
You can enter Search strings only, both Search and Replace strings, Path and mask strings only, or all the fields in a script. You can also override some of the values from the main window by entering new Search and Replace strings or new Path and Mask strings.
When a script is active, the Search, Replace, File Mask, and Path fields in the Search and Replace main window will change to reflect the script in use. For example, given a script named, example.srs, which only has settings for a search string, the Search field in the main window will change to read “Use Script file: d:\example.srs“. If example.srs also involved a replace string and a file mask, the Replace and File Mask fields would also change to read, “Use Script file: d:\example.srs“.