zotero/resource/redirect.vbs
Dan Stillman a9ca6e0857 Support unmodified Xpdf binaries
Use stdout redirection scripts for pdfinfo and, on Windows, a script to
run pdftotext hidden, which together allow for all unmodified binaries
(including, probably, symlinked system ones, though I didn't test that).

On Windows, using a .vbs does cause a brief wait cursor. The stock
pdfinfo needs the redirection script anyway, so that's unavoidable, but
on the async branch I think we'll be able to switch to pdf.js for the
page count, at which point maybe I'll try to remember how I modified the
Windows binaries to be hidden and use a modified version of pdftotext to
avoid VBScript. (We use the stock pdftotext elsewhere already.)
2015-04-01 04:36:21 -04:00

33 lines
886 B
Text

Option Explicit
Dim WshShell
Dim fso
Dim exe, src, dest
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
If Not(Wscript.Arguments.Count = 3) Then
Wscript.Echo "Usage: redirect.vbs <.exe file> <source file> <text file>"
WScript.Quit 1
End If
exe = WScript.Arguments(0)
src = WScript.Arguments(1)
dest = WScript.Arguments(2)
If Not(fso.FileExists(exe)) Then
WScript.Echo "Executable not found: " & exe
WScript.Quit 1
End If
If Not(fso.FileExists(src)) Then
WScript.Echo "Source file not found: " & src
WScript.Quit 1
End If
If Not(fso.FolderExists(Left(dest, InstrRev(dest, "\")))) Then
WScript.Echo "Destination folder not found: " & Left(dest, InstrRev(dest, "\"))
WScript.Quit 1
End If
WshShell.Run "%comspec% /c " & exe & " " & chr(34) & src & chr(34) & " > " & chr(34) & dest & chr(34), 0, true