Ps2txt command line
Hi
I have downloaded your trial version which looks as though it works on
our .ps files running it from a command line. I have about 20 files I
want to convert to text, preferably in a batch job, how do I do this and
what license do I need.
Regards
=================================
You can run following command line to convert all PS files to text files
at one time,
#1: Convert all PS files to TXT files in D:\temp folder,
for %F in (D:\temp\*.ps) do "C:\VeryPDF\ps2txt.exe" "%F" "%~dpnF.txt"
Postscript to Text Converter Server License is USD195 per server, you
can purchase it from our website directly,
http://www.verydoc.com/ps-to-text.html
VeryPDF
===================================
is it possible to run this from within a python script and if so how do I do it?
===================================
ps2txt.exe is a command line application, you can call it from any script, of course, you can call it from python script too, please refer to following sample code,
~~~~~~~~~~~~~~~~~~~~~~
import commands
( stat, output ) = commands.getstatusoutput( "C:\VeryPDF\ps2txt.exe C:\test.pdf C:\out.txt" )
if( stat == 0 ):
print "Command succeeded, here is the output: %s" % output
else:
print "Command failed, here is the output: %s" % output
~~~~~~~~~~~~~~~~~~~~~~
VeryPDF
======================================
HI sorry to be a pain but I have 2 questions ifrstly when I ran the script you suggested I got:
Command failed, here is the output: '{' is not recognized as an internal or external command,
operable program or batch file.
so I am not sure what I should be changing, it is python 2.6 I am using.
Secondly assuming we do get it to work what changes do I need to make to pick out all .ps files from a mixed directory to produce a txt file for each ps file of the same name
Regards
======================================
You need use correct path to the ps2txt.exe, for example, if you place ps2txt.exe to C:\ folder, you need use following code,
( stat, output ) = commands.getstatusoutput( "C:\ps2txt.exe C:\test.pdf C:\out.txt" )
You can call following command line from a .bat file to Convert all PS files to TXT files in D:\temp folder,
For %%F in (D:\temp\*.ps) do "C:\VeryPDF\ps2txt.exe" "%%F" "%%~dpnF.txt"
You can then call this .bat file form your Python code, for example,
( stat, output ) = commands.getstatusoutput( "C:\test.bat" )
VeryPDF
======================================
Hi I have now got ps2txt.exe running from Python under Windows. import commands does not work under Windows so I had to use this instead:
def getstatusoutput(cmd):
"""Return (status, output) of executing cmd in a shell."""
"""This new implementation should work on all platforms."""
import subprocess
print cmd
pipe = subprocess.Popen(cmd, shell=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = str.join("", pipe.stdout.readlines())
sts = pipe.wait()
print sts
print output
if sts is None:
sts = 0
return sts, output
cmd = 'C:/ps2txt/ps2txt/ps2txt.exe "C:/ps2txt/ps2txt/test.ps" "C:/ps2txt/ps2txt/ab.txt"'
getstatusoutput(cmd)
which worked for a single file. So I then tried your for statement initiall from a bat file then from the command line and I got this
so the question now is what am I doing wrong on the command line or in the bat file which is behind the commandline window in the picture
Thank you
========================================
We have sent an example to you just now, please check it.
Thank you.
VeryPDF