Skip to Main Content

University Library, University of Illinois at Urbana-Champaign

MarcEdit

An introduction to the MARC record editing software MarcEdit

Overview

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. 

Creating a Script with the Script Wizard

  1. The scripting wizard can be found in the main window under the Add-Ins menu on the toolbar, as below:

                                              
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.

  1. To use the conditional feature, select the “Use conditional” box, which will activate a field to enter a search string. The default will be to use a string matching query, though you can also use a regular expression. This function allows you to either add or delete a field based on the presence of another field. Then enter the field you would like to use in the script as the field which will trigger the addition of the new field. For example, if I wanted to add or delete a field based on the presence of a 938 field which contains the string “Kirtas Technologies,” the screen would look like this:

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.

  1. Once you have entered the conditional field (if applicable), enter the new field you would like to add or delete in the second set of text boxes if the condition outlined above is met. For example, if I wanted to do something to a 999 field with the string “testdata” in subfield a, the screen should look like this: 

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.

  1. Once you have entered the field you would like select either add or delete the field specified in the second set of text boxes. In my example this is the 955$atestdata field. Once you have selected Add or Delete, text will appear in the Parameters box, as below:

                                            

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:  

  1. One parameter that is useful to know about can be found in the Additional options tab. Here you can select whether you want MarcEdit to sort the created field in numeric order by selecting “Sort fields numerically” under Other options as seen below:

                                             

  1. Once you have added all the parameters you would like to your script, click the save icon in the bottom left hand corner.  You will be prompted with a folder window where you can dictate what type of scripting file it will be saved as. As of the writing of this documentation, VBS and PERL were the only options.
  2. Once saved, the script can be found in the specified directory. 

Modify Field Data in Script

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.

  1. The scripting wizard can be found in the main window under the Add-Ins menu on the toolbar, as below:

The following dialog box should appear:

                                                      

  1. Select the “Modify” tab at the top of the dialog box. The dialog box should change to something like this:

                                                  

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”:

                                            

 

  1. Next enter the field that you would like to modify in the bottom section of the dialog box. This does allow you to specify the subfield, so using the $[subfield] code in the search string is not necessary. You can also have MarcEdit find and replace existing text, though unlike the utilities within the MarcEditor itself, leaving this blank will not replace anything within the subfield with the text you would like added. Rather, because it is interacting directly with the template script, it will search for an empty string, which will result in the modification not being made. This function proved most useful when trying to make a regular modification to strings present in all records or to specific strings rather than trying to modify the contents of a specific subfield regardless of content. To do this I would recommend using the Editing Subfield Data function and incorporating it into a task rather than use a script wizard, as searching with a regular expression does not appear to be possible in the most current release of MarcEdit. For example, if I wanted to modify all 049$a subfields which contained the string UIUU and replace them with University of Illinois, the screen should look like this:  

                                             

If the “Add subfield if not present box” is checked, a subfield will be created with the desired text.

  1. Click Apply to generate the parameter for the script. You can also add Add/Delete functions to your script, which will be executed in the order entered. The full workflow for Adding and Deleting fields in a script can be found here: Creating a Script with the Script Wizard
  2. Once you have added all the parameters, click the “Save Script” button in the bottom right hand corner of the dialog box. You will be prompted with a folder window where you can dictate what type of scripting file it will be saved as. As of the writing of this documentation, VBS and PERL were the only options.
  3. Once saved, the script can be found in the specified directory. 

Editing an Existing Script

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

  1. Open the script wizard from the main menu by selecting Add-insàMarcEdit Script Wizard as if you were creating a new script.
  2. Select the open script icon from the Script Wizard Window as seen below:

                                              

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.

Executing a Script on a File

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.

  1. Perhaps the simplest option, depending on where your script and your file are stored, is to drag file you would like the script to use onto the script itself, as shown below:

                            
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.

 

  1. Once a script has been generated, you can run it by either double clicking on the script, which will prompt you for the address of the file you would like the script run on as below:

                             
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.

                                                  

  1. Once the address is in the dialog box, click OK. 

 

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.

  1. Once you open the file resulting from the script, you can compile it into MARC by selecting FileàCompile File into MARC from the MarcEditor window