Guest User

Untitled

a guest
Nov 29th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. ' a script to export marc records from Horizon skipping known bad bibs
  2. ' NOTE: it will overwrite previous exports
  3.  
  4. Dim dir, marcout, server, db, user, pass, outfile, outfilepath, logfile, logfilepath, filesys, maxbib, badbibs, currentbib
  5.  
  6. ' set some parameters
  7. server = "yourserver"
  8. db = "yourdb"
  9. user = "user"
  10. pass = "secret"
  11.  
  12. minbib = 1
  13. maxbib = 90000
  14.  
  15. ' set any badbibs here, or set badbibs to and empty array if there are no badbibs: badbibs = Array()
  16. badbibs=Array(8275, 55870, 72053, 81145, 88132)
  17.  
  18. dir = "C:\\local\\horizon\\"
  19.  
  20. ' set any marcout params here - see the marcout docs for details
  21. marcout = dir & "marcout /S" & server & " /U" & user & " /P" & pass & " /D" & db & " /Xfull /Y /Q967"
  22.  
  23.  
  24. ' set up the logging
  25. logfilepath = dir & "export\\marcout.log"
  26. Set filesys = CreateObject("Scripting.FileSystemObject")
  27. Set logfile = filesys.CreateTextFile(logfilepath, True)
  28.  
  29. logfile.WriteLine("Command: " & marcout)
  30.  
  31.  
  32.  
  33. Set objShell = CreateObject("WScript.Shell")
  34.  
  35. if UBound(badbibs) >= 0 Then
  36. for b = 0 to UBound(badbibs)
  37.  
  38. logfile.WriteLine("**** Skipping bad bib number: " & badbibs(b) & " *******")
  39.  
  40. If b = LBound(badbibs) Then
  41. ' we are at the first bad bib
  42. End If
  43. call runexport(minbib, badbibs(b) -1)
  44.  
  45. If b > 0 and b < UBound(badbibs) Then
  46. call runexport(badbibs(b) + 1, badbibs(b+1) -1)
  47. End If
  48.  
  49. If b = UBound(badbibs) Then
  50. ' we are at the last badbib
  51. call runexport(badbibs(b) + 1, maxbib)
  52. End If
  53.  
  54. next
  55. Else
  56. ' there are no bad bibs, so just run a complete dump
  57. call runexport(minbib, maxbib)
  58. End if
  59.  
  60.  
  61. set objStdOut = Nothing
  62. set objShell = Nothing
  63. set objWshScriptExec = Nothing
  64. set logfile = Nothing
  65. set filesys = Nothing
  66.  
  67.  
  68.  
  69. ' subroutine to run the marcexport for a batch of bibs
  70. Sub runexport(startbib, endbib)
  71.  
  72. if(startbib <= endbib) Then
  73.  
  74. batchoutfile = "recs" & startbib & "_" & endbib & ".mrk"
  75.  
  76. 'delete the files before we continue
  77. If filesys.FileExists(batchoutfile) Then
  78. filesys.DeleteFile batchoutfile
  79. logfile.WriteLine("**Deleted file: "& batchoutfile)
  80. End If
  81.  
  82. Set objWshScriptExec = objShell.Exec(marcout & " /M" & batchoutfile & " /B" & startbib & " /E" & endbib)
  83. Set objStdOut = objWshScriptExec.StdOut
  84.  
  85. '- read output from command'
  86. While Not objStdOut.AtEndOfStream
  87. logfile.WriteLine(objStdOut.ReadLine)
  88. Wend
  89. End if
  90. End Sub
Add Comment
Please, Sign In to add comment