Scripts - Linked Scripts

Search and Replace version 3.4+ has a special script operator that allows two or more scripts to be 'chained' in succession. The same effect is achieved in earlier versions by using .bat/.cmd files to launch sequential instances of the program, each instance to run a different script. The Script Link function in version 3.4 can be useful to those who are uncomfortable with .bat/.cmd files.

The syntax for linking scripts is modeled at the bottom of the script below. For version 3.4 you must create/edit scripts that contain Script Link instructions with your text editor. The version 3.4 internal Script Editor respects existing Script Link references but you cannot create them via the Script Editor.

Please read through this entire section before you use Script Linking for the first time!

Example Script with Script Link References

[Script for Search and Replace]
[Search /i]
something
[Replace]
something
[Path]
D:\TEST\somefile.txt
[End of Search and Replace Script]
D:\TEST\Script2.srs
D:\TEST\Script3.srs
D:\TEST\Script4.srs
...(Additional scripts)...
D:\TEST\ScriptLast.srs

Script Link references are placed at the bottom of a script file, below the [End of Search and Replace Script] tag. The format is to specify the full path name to a script file.

Notes:

Usage Suggestions

Case 1 - Linking a mixture of Search-Only and Search-Replace operations

Create separate initial scripts for each type of operation. For example, if you wish to perform some replaces and then a search, chain your search-replace scripts and then separately launch your search-only script. A .bat command line for this might be

start /w c:\tools\sr\sr32.exe /r /c"c:\tools\sr\scripts\replaces.srs" /q
start /w c:\tools\sr\sr32.exe /s /c"c:\tools\sr\scripts\search.srs" /q

The script 'c:\tools\sr\scripts\replaces.srs' might can contain one or more links to other search-replace operation scripts. Do not make a mistake and put a script link reference to a script intended as a search-only script in 'replaces.srs' - the program will perform a replace instead because you launched that script via a search-replace.

Case 2 - Using 'Launching' Scripts'

You can use scripts that accomplish nothing meaningful as launching points for linking scripts. Let's say you have a series of complex scripts the require debugging and you want to easily test these in sequence. Instead of specifying the linked script references in a main script, create one or more scripts whose sole purpose is to launch your main scripts.

Since all scripts must have some kind of valid operation, your 'launching' scripts must contain valid search-replace strings. However, you can use 'dummy' strings that would never be found in any file. Likewise, you can use a path/mask that refers to a file that does not exist on your drive.

Example:

[Script for Search and Replace]
[Search]
bbbbbbbbbb
[Replace]
bbbbbbbbbb
[Path]
D:\TEST\this_file_does_not_exist.txt
[End of Search and Replace Script]
D:\TEST\Script2.srs
D:\TEST\Script3.srs

The script above accomplishes nothing - even if the file, 'this_file_does_not_exist.txt',. is present on your drive, if launched as a search-replace, the operation itself changes nothing because the strings are identical.