MarcEdit 5.8: Using the Command-line tool

One thing that many people do not always realize is that MarcEdit includes a console application as part of the MarcEdit package.  This is a separate program, cmarcedit.exe.  The tool is designed to provide quick access to the MARCEngine functions (making/breaking) as well as character conversions, etc.  Since documentation on this tool is light (something I’ll try and change this weekend) — I wanted to quickly provide some information on how to use some of the basic functions. 

Before using the command-tool, I’d recommend creating an environmental variable to stand in for the path to MarcEdit.  This will ensure on windows that you are not having to type the path to the MarcEdit file path each time you want to run the tool.  My environmental variable is %MARCEDIT% so you’ll see that show up in my examples.

Command line options — type c:\%MARCEDIT%/cmarcedit.exe —h  This will generate the following list:

***************************************************************
* MarcEdit 5.8 Console Application
* By Terry Reese
* Oregon State University

* email: terry.reese@oregonstate.edu

* Modified: 2012/10/19
***************************************************************
Arguments:
        -s:     Path to file to be processed.
                        If calling the join utility, source must be files
                        delimited by the ";" character
        -d:     Path to destination file.
                          If call the split utility, dest should specify a folder
                        where split files will be saved.
                        If this folder doesn’t exist, one will be created.
        -mxslt: Path to the MARCXML XSLT file.
        -xslt:  Path to the XML XSLT file.
        -batch: Specifies Batch Processing Mode
        -character:     Specifies character conversion mode.
        -break: Specifies MarcBreaker algorithm
        -make:  Specifies MarcMaker algorithm
        -marcxml:       Specifies MARCXML algorithm
        -xmlmarc:       Specifics the MARCXML to MARC algorithm
        -marctoxml:     Specifies MARC to XML algorithm
        -xmltomarc:     Specifies XML to MARC algorithm
        -join:  Specifies join MARC File algorithm
        -split: Specifies split MARC File algorithm
        -records:       Specifies number of records per file [used with split command].
        -raw:   [Optional] Turns of mnemonic processing (returns raw data)
        -utf8:  [Optional] Turns on UTF-8 processing
        -marc8: [Optional] Turns on MARC-8 processing
        -pd:    [Optional] When a Malformed record is encountered, it will modify the process from a stop process to one where an error is simply noted and a stub note is added to the result file.
        -help:  Returns usage information

Operations:

  • MarcBreaker — to replicate the MarcBreaker functionality, you need to utilize the —break switch in combination with the —s and —d.  If you wish to include character encoding arguments, you’d include the —utf8 or —marc8 options as well.
    Example: c:\%MARCEDIT%\cmarcedit.exe —s “c:\users\reeset\desktop\test.mrc” —d “c:\users\reeset\desktop\test.mrk”
  • MarcMaker — to replicate the MarcMaker functionality, you need to utilize the —make switch in conjunction with the —s and —d switches.  If you wish to include character encoding arguments, you’d include the —utf8 or the —marc8 options as well.
    Example:  c:\%MARCEDIT%\cmarcedit.exe —s “c:\users\reeset\desktop\test.mrk” —d “c:\users\reeset\desktop\test1.mrc”
  • MARC2MARCXML — to replicate the ability to generate MARC to MARCXML — you would use the —marcxml switch in conjunction with the —s and —d options.  You do not need to specify character conversion — MarcEdit always converts data to UTF8 when dealing with XML.
    Example: c:\%MARCEDIT%\cmarcedit.exe —s “c:\users\reeset\desktop\test.mrc” —d “c:\users\reeset\desktop\test.xml” —marcxml
  • MARCXML2MARC — to replicate the ability to generate MARCXML to MARC — you will use the —xmlmarc switch in conjunction with the —s and —d options.  If you wish to convert the results into MARC-8, you can include the —marc8 switch as well. MarcEdit includes two MARCXML processing algorithms.  By default, it uses the native function — but you can force the application to use DOM when processing MARCXML back to MARC by including —mxslt option as well.
    Example Native Function:  c:\%MARCEDIT%\cmarcedit.exe —s “c:\users\reeset\desktop\test.xml” —d “c:\users\reeset\desktop\test2.mrc” —xmlmarc

    Example XSLT Function:  c:\%MARCEDIT%\cmarcedit.exe —s “c:\users\reeset\desktop\test.xml” —d “c:\users\reeset\desktop\test2.mrc” —xmlmarc —mxslt “E:\users\reeset\marcedit\net_marcedit\C#\MProgram\MarcEdit\bin\Debug\xslt\MARCXMLSlim.xsl”

  • MARC to XML format –  You can convert directly to other XML formats — like MODS, using the —marctoxml option.
    Example c:\%MARCEDIT%\cmarcedit.exe —s “c:\users\reeset\desktop\test.mrc” —d “c:\users\reeset\desktop\test.xml” —marctoxml —xslt “E:\users\reeset\marcedit\net_marcedit\C#\MProgram\MarcEdit\bin\Debug\xslt\MARC21slim2MODS3.xsl”
  • * XML to MARC — You can convert directly from other XML functions like MODS back to MARC using the —xmltomarc option.
    Example:  c:\%MARCEDIT%\cmarcedit.exe —s “c:\users\reeset\desktop\test.xml” —d “c:\users\reeset\desktop\test3.mrc” —xmltomarc —xslt “E:\users\reeset\marcedit\net_marcedit\C#\MProgram\MarcEdit\bin\Debug\xslt\MODS2MARC21slim.xsl”

–TR

* The xml to marc switch is new as of the update posted Oct. 28, 2012.


Posted

in

by

Tags:

Comments

4 responses to “MarcEdit 5.8: Using the Command-line tool”

  1. Duane Meyers Avatar
    Duane Meyers

    Can’t get enough of command line tools. Plunk them in a batch file and can use it over and over
    Is there a command to remove subfields

    Duane Meyers

    1. Administrator Avatar
      Administrator

      There isn’t specifically no. The command line tools primarily provide access to the engine for converting and processing MARC/XML data. If there was interest — I could provide a few editing commands — but I’d likely keep them simple — basic functions for maybe adding a field and deleting a field. If you really needed to do more than that — I’d recommend writing a shell script to process the file after it was broken and then reprocessing the data via the command line after the changes were made.

      –TR

  2. Mace Ojala Avatar

    Hi there. For editing MARC records, there’s a tool called USEMARCON, which is quite useful.

    Anyways, i’ve been looking for ways to validate MARC data, and MarcEdit comes with MARCValidator, which produces quite nice reports of our data… though not very flattering i’m afraid. Anyways, i don’t think MARCValidator is available from the command line, which would be totally sweet. Any ideas for automating MARC validation? I’m thinking of setting up an automated validating process, which would give feedback to the cataloguing department on a daily/weekly basis about the data they are adding to the database, using regular OAI-PMH harvesting to export the fresh records. Hmm, i guess you could think of it as a computer peer-reviewing the work the cataloguers do.

    1. Terry Reese Avatar
      Terry Reese

      Mace,

      So, the Validator really is there for providing simple validation and helping users identify invalid data that might cause issues when trying to convert data between MARC and the mnemonic formats. So, admittedly, the format of the report is basic. If you need something more robust, there are lots of great tools, including the MARC::LINT library that provides a great many validation options.

      However, it is incorrect to say that the validation cannot be run from the command-line — it can, it’s just undocumented. It’s one of the a handful of functions that are, I guess for lack of a better term, easter eggs, because they exist and exist primarily because I have a need for them, but are not documented. So, I can change that. I’ll make sure the validation switch shows up in the next update — which will be over Christmas.

      –tr