Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' a script to export marc records from Horizon skipping known bad bibs
- ' NOTE: it will overwrite previous exports
- Dim dir, marcout, server, db, user, pass, outfile, outfilepath, logfile, logfilepath, filesys, maxbib, badbibs, currentbib
- ' set some parameters
- server = "yourserver"
- db = "yourdb"
- user = "user"
- pass = "secret"
- minbib = 1
- maxbib = 90000
- ' set any badbibs here, or set badbibs to and empty array if there are no badbibs: badbibs = Array()
- badbibs=Array(8275, 55870, 72053, 81145, 88132)
- dir = "C:\\local\\horizon\\"
- ' set any marcout params here - see the marcout docs for details
- marcout = dir & "marcout /S" & server & " /U" & user & " /P" & pass & " /D" & db & " /Xfull /Y /Q967"
- ' set up the logging
- logfilepath = dir & "export\\marcout.log"
- Set filesys = CreateObject("Scripting.FileSystemObject")
- Set logfile = filesys.CreateTextFile(logfilepath, True)
- logfile.WriteLine("Command: " & marcout)
- Set objShell = CreateObject("WScript.Shell")
- if UBound(badbibs) >= 0 Then
- for b = 0 to UBound(badbibs)
- logfile.WriteLine("**** Skipping bad bib number: " & badbibs(b) & " *******")
- If b = LBound(badbibs) Then
- ' we are at the first bad bib
- End If
- call runexport(minbib, badbibs(b) -1)
- If b > 0 and b < UBound(badbibs) Then
- call runexport(badbibs(b) + 1, badbibs(b+1) -1)
- End If
- If b = UBound(badbibs) Then
- ' we are at the last badbib
- call runexport(badbibs(b) + 1, maxbib)
- End If
- next
- Else
- ' there are no bad bibs, so just run a complete dump
- call runexport(minbib, maxbib)
- End if
- set objStdOut = Nothing
- set objShell = Nothing
- set objWshScriptExec = Nothing
- set logfile = Nothing
- set filesys = Nothing
- ' subroutine to run the marcexport for a batch of bibs
- Sub runexport(startbib, endbib)
- if(startbib <= endbib) Then
- batchoutfile = "recs" & startbib & "_" & endbib & ".mrk"
- 'delete the files before we continue
- If filesys.FileExists(batchoutfile) Then
- filesys.DeleteFile batchoutfile
- logfile.WriteLine("**Deleted file: "& batchoutfile)
- End If
- Set objWshScriptExec = objShell.Exec(marcout & " /M" & batchoutfile & " /B" & startbib & " /E" & endbib)
- Set objStdOut = objWshScriptExec.StdOut
- '- read output from command'
- While Not objStdOut.AtEndOfStream
- logfile.WriteLine(objStdOut.ReadLine)
- Wend
- End if
- End Sub
Add Comment
Please, Sign In to add comment