Running Scripts
Use the Script Editor window or the Scripting submenu on the Tools menu
to run scripts.
IMPORTANT
Scripts can pose a security risk to your computer. A script has
the power to delete files, read files, write files, execute programs,
access the Internet, access files on your network, and so on. Always examine
the contents of a script before running it. If you don't understand the
script, do not run it unless it comes from a trusted source. In general,
take the same precautions you would take for any program you download
from the Internet or receive in an e-mail attachment.
-
Click in the data window where
you want to apply the script to establish focus.
-
From the View menu, choose
Script Editor
to display the Script Editor window if it isn't already displayed.
-
Click the Open
button
in the Script Editor toolbar. The Open Script window is displayed.
-
Select the script file (.vb,
.js, .cs, or .dll) you want to run. The contents of the script are displayed
at the bottom of the Script Editor window.
-
If you need to pass an argument
to the script, type it in the Script
Args box. Arguments are specified as follows:
ArgName=ArgValue&ArgName2=ArgValue2.
. .
For example, a script that uses an argument to indicate where files
should be saved could use the following argument to save files to a ScriptOutput
folder on your D:\ drive: dir=d:\ScriptOutput.
If your script can create a log file to record the results of a scripting
operation, you could append that argument as follows: dir=d:\ScriptOutput&logFileName=myLog.txt.In this example, the ampersand (&)
separates the two arguments, the first argument set the save folder, and
the second argument sets the file name for the log file.
-
Click the Run
Script button
.
-
Click in the data window where
you want to apply the script to establish focus.
-
From the Tools menu, choose
Scripting.
-
Choose a script from the submenu
or choose Run Script
from the submenu to browse to the script file (.vb, .js, .cs, or .dll)
you want to run.
In addition to running scripts from the Script Editor and
the Scripting menu, you can run scripts directly from the command line
using the following commands.
SCRIPT
Starts Sound Forge Pro and runs the specified script.
Example:"C:\Program
Files\BorisFX\Sound Forge Pro2026.0\Forge20260.exe"
-SCRIPT: "C:\Scripts\MyScript.cs"
SCRIPTARGS
Starts Sound Forge Pro and passes the specified arguments to
a script.
Example:"C:\Program
Files\BorisFX\Sound Forge Pro2026.0\Forge20260.exe"
-SCRIPTARGS: "in\C:\Test\input.dls&out=C:\Test\Output.dls&repeat=2"
-SCRIPT: "C:\Scripts\MyScript.cs"
EXIT
Exits Sound Forge Pro after running the specified script.
Example: "C:\Program
Files\BorisFX\Sound Forge Pro2026.0\Forge20260.exe"
-SCRIPT: "C:\Scripts\MyScript.cs" -EXIT
A script can accept arguments to dynamically change the
behavior of a script. Arguments allow you to develop a single script that
performs multiple functions controlled by the arguments sent to the script.
Each argument is a key/value pair. The key is a string that
identifies the argument’s value. Multiple arguments are delimited by an
ampersand (&).
Example:
key1=value1&key2=value2&key3=value3…
When you supply arguments to a script, the following static
functions can be used to extract and format the parameters:
public static string GETARG(string key,
string str) { string val = Script.Args.ValueOf(key);
if (val == null) val = str; return val; }
public static int GETARG(string key, int ii) { return Script.Args.AsInt(key,ii);
}
public static Int64 GETARG(string key, Int64 cc) { return
Script.Args.AsInt64(key,cc); }
public static bool GETARG(string key, bool ff) { return
Script.Args.AsBool(key,ff); }
public static double GETARG(string key, double dd) { return
Script.Args.AsDouble(key,dd); }
The first argument to the GETARG functions specifies a key
name that is used to identify the argument to be extracted. The second
argument in the GETARG function is a default value to be returned if the
function cannot find the key name. The second argument also determines
which overloaded function the script will use and how the value will be
formatted.
For example, consider a script that accepts three input
parameters. The syntax for the arguments is as follows:
in=C:\Test\input.dls&out=C:\Test\output.dls&repeat=2
The script to handle the parameters would look as follows:
using System;
using System.IO;
using System.Collections;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Drawing;
using SoundForge;
using SoundForge.BatchConverter;
public class EntryPoint {
public string Begin(IScriptableApp app) {
string inFile =
GETARG("in", "");
string outFile = GETARG("out", "" );
int count = GETARG("repeat", 0 );
When you start the program, Sound Forge Pro software looks at
the Script Menu folder in the Sound Forge Pro program folder to determine
which scripts appear in the Scripting submenu. This folder is c:\Program
Files\BorisFX\Sound Forge Pro2026.0\Script Menu by default.
-
Add or delete scripts in the
Script Menu folder to change the contents of the submenu.
TIP To prevent duplication of script files, you
can use shortcuts in the Script Menu folder.
-
From the Tools menu, choose
Scripting, and
then choose Rescan Script
Menu Folder to update the menu.
TIP If you want to display custom icons for scripts
in the Scripting menu and toolbar, you can create icons as .png files
in your Script Menu folder. For more information, please see The
Scripting Toolbar.