According to the developer, the Script Wizard function was initially developed as a way to provide automation tools before the development of the task manager. Because the task manager allows for a wider range of functions to be automated and requires no programming knowledge, it is perhaps more effective for most users. However, there may be cases where less interaction with the user interface is preferred. One example noted by the developer is when working with large datasets (500MB-500GB), which the user interface could handle but which might be faster if handled with a script. Furthermore, scripts which are executed generate a new copy of the file rather than modifying the original. The naming conventions for these files and where they are stored will be discussed in the workflow outlining the process of executing a script on a file.
The script wizard allows users to make changes to the template scripts that are used when commands are executed from the graphic interface and then save them so that they can be executed on .mrk (Mnemonic) files directly and as needed. These workflows will show how to use the script wizard and how to execute the scripts on a Mnemonic file. The script that you create with this wizard can be saved in either PERL or VBScript. I will also show how to find the template scripting file which can be edited in either PERL or VBS. While this does allow for even greater control compared to the user interface or script wizard, once changes are made to a file with a text editor they can no longer be edited using the script wizard.
The following dialog box should appear:
This screen will hold the commands of the script as you create them. The first tab demonstrates how to add or delete fields either conditionally or unconditionally.
If you do not wish to use a conditional test, leave this area blank. Also, the arrow next to the HAS box allows you to toggle between a string matching query and a regular expression query.
If you would like to add or delete a field without any conditional statement, be sure the “Use conditional” box is unchecked then enter the field data would want added or deleted in this field. Notice that the Field Data box contains the notation for subfield. This is essential if you want the script to add the data into a subfield and not just into the field. Similarly, the indicators must be specified in order to be included, though they are set to \\ by default when the script wizard is opened.
In this example I have chosen to delete the field. If I were to select add, the text which appears would be the same, only “ADD” would take the place of “DEL.”
For a more in-depth workflow for the Modify and Additional Options tabs, see the workflows dedicated to those functions(Modify Field Data In Script, Additional Options), as they demonstrate how they are utilized as well as how to add them to an existing scripts. If you would like to delete a command from the parameter list, right click on the parameter and select “Delete Item,” as below:
This workflow outlines how to use MarcEdit’s script wizard to modify data in a particular field and include it within a script. While the screen does not necessarily make this explicit, it is possible to include this within other scripting options. This means if a script is generated which modifies a field it can be included into a script which adds or deletes a field outlines in the workflow immediately preceding this one.
The following dialog box should appear:
The first section of the dialog box is meant to apply a conditional statement connected to the field modification. The second half is where the actual field modification will be input. You have the option of including the conditional as a string match or as a regular expression. To use the conditional, be sure that “Use Conditional” is checked. The “If” text box should contain the field that the script will look for in order to trigger the field modification. To use a string matching, you can keep the “HAS,” though if you’d like to use a regular expression click the arrow next to “HAS,” which allows you to enter the search terms (in either form) next to the “HAS” or “REGEX” box.
By the developers admission, the modify field functionality in the scripting wizard is a bit buggy, and in testing for this documentation I certainly found that to be the case, especially when using regular expressions in the conditional statements. I found that using the string matching was more successful, though it is important to include the $[subfield] code as seen below. This example will modify a field if the 336 field contains a subfield a with the string “text”:
If the “Add subfield if not present box” is checked, a subfield will be created with the desired text.
If you have created a script but would like to add additional commands or remove some commands, it is possible to do so using the same Script Wizard window used to create the script. Note: you can only edit scripts that were generated in MarcEdit using the Script Wizard. If you try to edit a script that you have either modified manually after using the Script Wizard or developed wholly on your own, those changes will be lost if you attempt to open and edit the script in the script wizard.
3. A folder window will open. Navigate to the directory which houses the script you would like to edit, select it, and click Open.
4. The parameters for that script will be found in the parameters window as of the last save, as below:
5. To delete a parameter, select it, right click, and a “Delete Item” option should appear. Select it and the parameter will disappear. To add a parameter, follow these workflows: Creating a Script with the Script Wizard and Modify Field Data in Script. Be sure to save the script when you have finished editing by selecting the save script icon.
This workflow outlines how a script made with the Script Wizard can be executed on a .mrk file. Note that the scripts must be in the MARC Mnemonic Format. To convert a MARC record into this format, follow workflow Create MARC File for Editing in MARC Editor. As there are two ways to run the scripts, I will outline both here. In order for the script to be run, it must be saved to the same folder where the document is saved.
This will generate a confirmation screen informing you how many records were processed using the script. It should look something like this:
The script will generate a new file with the specified changes using the convention “[original file name]rev” in the same directory where both the original file and the script were saved.
Note that by “tab delimited” format, it is referring to the .mrk file, not a delimited text file. The path can be found by right clicking the .mrk file and slecting “Properties.” From here click the “Security” tab (shown below), where you can find the address. Copy the whole address into the text box.
The script will generate a new file with the specified changes using the convention “[original file name]rev” in the same directory where both the original file and the script were saved.