I have a batch file set up to run a ghostscript which creates a .pdf output, which I then want to use in a subsequent python script. The batch file itself runs without issue and looks like this:
"%PROGRAMFILES%gsgs9.54.0bingswin64c.exe" -dBATCH -dSAFER -dNOPAUSE -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dAutoRotatePages=/PageByPage -r600 -sOutputFile=%~dp0%result%.pdf - ^& "%~dp0test.py" %result%.pdf
The batch file log shows that it executes all commands. Furthermore, a dummy python script that does nothing but log that it ran also works perfectly. However, when I substitute the dummy for the script I want to use, the file does not do what it should, despite running perfectly when run on its own from the console. The python script looks like this:
import os import sys from rmapy.document import ZipDocument from rmapy.api import Client # sets up the current directory to be the same as the .py file os.chdir(os.path.dirname(os.path.abspath(__file__))) # sets up the remarkable api rm=Client() rm.renew_token() # finds the pdf for arg in sys.argv[1:]: print(arg) rawDocument = ZipDocument(doc=arg) rawDocument.metadata["VissibleName"] rm.upload(rawDocument)
I highly appreciate any help you are able to offer. I suspect there is something in the .py file that produces an error when called through the batch file, but I can’t figure out what.
Source: Windows Questions