1. Click in the data window where you want to apply the script to establish focus.

  2. From the View menu, choose Script Editor to display the Script Editor window if it isn’t already displayed.

  1. Click the Open button Sound Forge Pro b open Running Scripts in the Script Editor toolbar. The Open Script window is displayed.

  2. 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.

  3. 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.

  4. Click the Run Script button Sound Forge Pro b runscript Running Scripts.

  1. Click in the data window where you want to apply the script to establish focus.

  2. From the Tools menu, choose Scripting.

  3. 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 and runs the specified script.

Example: “C:\Program Files\Sony\Sound Forge Pro 10.0\Forge100.exe” -SCRIPT: “C:\Scripts\MyScript.cs”

SCRIPTARGS

Starts Sound Forge and passes the specified arguments to a script.

Example: “C:\Program Files\Sony\Sound Forge Pro 10.0\Forge100.exe” -SCRIPTARGS: “in\C:\Test\input.dls&out=C:\Test\Output.dls&repeat=2″ -SCRIPT: “C:\Scripts\MyScript.cs”

EXIT

Exits Sound Forge after running the specified script.

Example: “C:\Program Files\Sony\Sound Forge Pro 10.0\Forge100.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 software looks at the Script Menu folder in the Sound Forge program folder to determine which scripts appear in the Scripting submenu. This folder is c:\Program Files\Sony\Sound Forge 10.0\Script Menu by default.

  1. Add or delete scripts in the Script Menu folder to change the contents of the submenu.

Sound Forge Pro tip Running ScriptsTo prevent duplication of script files, you can use shortcuts in the Script Menu folder.

  1. From the Tools menu, choose Scripting, and then choose Rescan Script Menu Folder to update the menu.

Sound Forge Pro tip Running ScriptsIf 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.

Running Scripts

Sound Forge Pro b showscripteditor Running Scripts

Ctrl+Alt+2

View Menu

Use the Script Editor window or the Scripting submenu on the Tools menu to run scripts.

Sound Forge Pro warning Running ScriptsScripts 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.


What do you want to do?

Sound Forge Pro arrowdn Running Scripts Run a script from the Script Editor window

Sound Forge Pro arrowdn Running Scripts Run a script from the Scripting menu

Sound Forge Pro arrowdn Running Scripts Run a script from the command line

Sound Forge Pro arrowdn Running Scripts Learn more about script arguments

Sound Forge Pro arrowdn Running Scripts Add scripts to the Scripting menu

Sound Forge Pro btnshowall Running Scripts

Running Scripts