This shows you the differences between two versions of the page.

Link to this comparison view

phelp:helprunmg [2016/08/22 17:55]
phelp:helprunmg [2016/08/22 17:57] (current)
Line 1: Line 1:
 +  runMG -  exe for launching TMQ's MARC Global in scriptable/batch mode
 +  The file runMG.exe must be installed in the MARC Report program folder.
 +  From there, you may create a shortcut to the exe and relocate the shortcut 
 +  wherever you desire. Or, create a shortcut for a command prompt, and then 
 +  configure the shortcut to start in the MARC Report program folder. But when
 +  running the program from a script, remember to specify the full path to the
 +  .exe (unless you have added that to your PATH Environment variable)
 +  runmg
 +  runmg "(marcInput|marcOutput|workingFolder|reviewFile)"
 +  runmg "(marcInput|marcOutput|workingFolder|reviewFile|marcOutput2)"
 +  runmg "(marcInput|marcOutput|workingFolder|reviewFile|reportFile)"
 +  A scriptable interface to TMQ's MARC Global utility (available as an
 +  add-on product to MARC Report). Records are read from the 'marcInput'
 +  file; the instructions in the 'reviewFile' are applied to each record;
 +  records are output to the 'marcOutput' file; any logs generated as a 
 +  result of the processing are output to the 'workingFolder'.
 +  When 'runMg' is called without any parameters, a small windows program
 +  is launched which makes it possible to enter the parameters using a form
 +  and test them.
 +  In all other cases, runMG must be launched with parameters matching one
 +  of the entries in the SYNOPSIS above. The parameter statement must begin
 +  with 
 +    "( 
 +  ... and end with 
 +    )"
 +  Each parameter, except the last, must be followed by the "|" separator.
 +  We strongly recommend using fully-qualified pathnames for the parameters.
 +  runMG gets its processing instructions from the 'reviewFile'. This file
 +  is an .xml file that must be created using the 'Export review' option in
 +  MARC Global.
 +  In general, use the following procedure to create a reviewFile (for
 +  details see the appropriate help files in MARC Global): start MARC 
 +  Global and setup the parameters for the job(s) that you want to run 
 +  in batch mode. Test the job, etc, then save it to your saved reviews. 
 +  Next, goto the 'Reviews' form, create an Autoreview, and add the 
 +  job(s) you want to run in batch mode to it. Exit the 'Reviews' form, 
 +  select 'Options', goto the 'Import/Export' tab, and use the 
 +  'Export review to .xml' option to export the Autoreview created above.
 +  Once the review has been exported into .xml, it becomes re-useable outside
 +  of the MARC Global program.
 +  runMG generates a summary each time it runs which contains the same information 
 +  as MARC Global's 'Result screen', followed by some runMG-specific details. 
 +  The filename for this log is 'runMg-' followed by the marcInput filename. This 
 +  logfile will be written to the workingFolder. Thus, for the first example 
 +  below, this log would be named 'd:\marc\runMG-in1.txt'.
 +  The name and location of this log can be changed in the fifth command-line 
 +  parameter (see the last example in the Synopsis), by giving a fully-qualified 
 +  filename that ends with the '.txt' extension. Note that if the fifth param
 +  does not end in '.txt' it will be assumed to be the name of a splitfile.
 +  The runMG-specific details in this log include the time taken to run the job 
 +  (hh:mm:ss) and the actual filenames used during the job. 
 +  When an an Autoreview is exported to xml, the program writes default
 +  'Output options' to the .xml file.  runMG will use these defaults when it
 +  runs the Autoreview, and also automatically avoid filename collisions; 
 +  however, when the autoreview is complete, runMG will rename the MARC 
 +  output files to the filenames specified in the command-line parameters
 +  'marcOutput' and 'marcOutput2' as applicable.
 +  Even if there is only one review that you want to use in runMG, that review
 +  must still be saved as an Autoreview in MARC Global before it is exported
 +  to xml. 
 +  When creating an Autoreview it will be helpful to remember that the name
 +  you assign to the Autoreview in MARC Global becomes the name assigned to 
 +  the .xml file created by the Export option; which in turn becomes the 
 +  filename that must be used as the 4th parameter in the runMG options. 
 +  It is also possible to add a MARC Review job to runMG. 
 +  This may be useful in batch processing, if you need to conditionally split 
 +  a file into two separate files and apply different processing to each file. 
 +  Once you have created and saved the necessary MARC Review job (assuming
 +  it splits the MARC source into two output files), follow these steps to
 +  get the review into runMG: start MARC Global (not MARC Review) and go to the
 +  'Reviews' form. Select the 'Include MR' option at the bottom of the screen
 +  (if this option does not appear there is an installation or registration
 +  problem). Create a new Autoreview. Add your MARC Review to the Autoreview, 
 +  press Save, and exit the form. Proceed to export the Autoreview as above.
 +  When using this reviewFile in a runMG task, you must supply a second output file
 +  parameter in the command-line:
 +    runmg "(marcInput|marcOutput|workingFolder|reviewFile|marcOutput2)"
 +  Note: when an Autoreview contains a MARC Review job, that must be the only
 +  review present in the Autoreview (this makes sense if you think about it).
 +The simplest case: 
 +  runmg "(d:\marc\in1.mrc|d:\marc\out1.mrc|d:\marc\|c:\reviews\add 001.xml)"
 +This job applies the Autoreview exported to 'add 001.xml' (which perhaps
 +uses MARC Global's "Add sequential number" option) to every record in 'in1.mrc' 
 +and writes the results to 'out1.mrc'.
 +A more interesting example:
 +  runmg "(d:\in.mrc|d:\out1.mrc|d:\work\|c:\xml\check264.xml|d:\out2.mrc)"
 +  runmg "(d:\out2.mrc|d:\out2-fixed.mrc|d:\work\|c:\xml\fix260.xml|d:\hopeless.mrc)"
 +  mconcat --sourcefile="d:\out2-fixed.mrc" --targetfile="d:\out1.mrc"
 +  runmg "(d:\out1.mrc|d:\out1-fixed.mrc|d:\work\|c:\xml\fixes.xml)"
 +The first step is a MARC Review task that splits the input file into two pieces
 +based on whether the 264 field is present or not. The second step applies a 
 +fix-up autoreview to the records from the first job that did not match (and were 
 +thus split to a separate file); this step in turn splits records that it cannot 
 +fix to a file called 'hopeless.mrc'. In step 3, the fixed file from step 2 is added 
 +back to the main file (using our [[help:mconcat|marc concatenation utility]]); finally, in step 4, a large autoreview containing various tasks is applied to the 
 +re-joined records.   
 +A .bat script for the above might look like this:
 +  c: 
 +  cd "\program files (x86)\tmq\marc report"
 +  @rem split source file on presence of 264
 +  runmg "(d:\in.mrc|d:\out1.mrc|d:\work\|c:\xml\check264.xml|d:\out2.mrc)"
 +  @rem check 260 tags in out2 and try to update to rda rules if possible
 +  @rem write records that fail to a separate file for later manual review
 +  runmg "(d:\out2.mrc|d:\out2-fix.mrc|d:\work\|c:\xml\fix260.xml|d:\hopeless.mrc)"
 +  @rem add the records with updated 260s back to the main file
 +  mconcat --sourcefile="d:\out2-fix.mrc" --targetfile="d:\out1.mrc"
 +  @rem run the standard suite of fixes 
 +  runmg "(d:\out1.mrc|d:\out1-fix.mrc|d:\work\|c:\xml\fixes.xml)"
 +  d:
 +To avoid repeating long paths in commands, use the windows 'set' command. For example:
 +  set myPath=d:\library\data\qualitycontrol\marc
 +and then reference the above path in the runMG parameter string:
 +    runmg "(%myPath%\in.mrc|%myPath%\in-ok.mrc|%myPath%\|c:\work\check XXX.xml|%myPath%\in-not-ok.mrc)"
 +For more details on this syntax, search the web for "windows set command".
 +Because of the default behavior used when assigning MARC Global output options, 
 +preserving the 'mglog' generated by MARC Global during multiple autoreviews 
 +becomes problematic. Because of the internal processing performed by the program 
 +to avoid using saved filenames (assuming that they will nearly always become 
 +invalid over time), the only feasible workaround for this problem is to rename 
 +the MARC Global log after each autoreview using the batch script; eg.
 +  c:
 +  cd "\program files (x86)\tmq\marc report"
 +  runmg "(d:\in.mrc|d:\in-ok.mrc|d:\work\|c:\work\check XXX.xml|d:\in-not-ok.mrc)"
 +  rename d:\work\mglog.txt d:\work\mglog-job1.txt
 +  runmg "(d:\in-ok.mrc|d:\in-ok-out.mrc|d:\work\|c:\work\fixes.xml)"
 +  rename d:\work\mglog.txt d:\work\mglog-job2.txt
 +  ...
 +Even if there is only one review that you want to use in runMG, that review
 +must still be saved into an Autoreview in MARC Global before it is exported
 +to xml. 
 +When an Autoreview contains a MARC Review job, that job must be the only review 
 +present in the Autoreview.
 +The program expects the workingFolder to be specified with a trailing backslash. 
 +For example, given a job where the marcInput filename is 'rdaFix', then if
 +  workingFolder=D:\work\
 +the report will be named
 +  D:\work\runMG-rdaFix.txt 
 +But if 
 +  workingFolder=D:\work
 +then the report will be named
 +  D:\workrunMG-rdaFix.txt
 +which is probably not what one would want.
phelp/helprunmg.txt · Last modified: 2016/08/22 17:57 by richard
Back to top
CC Attribution-Noncommercial-Share Alike 3.0 Unported
Driven by DokuWiki Recent changes RSS feed