Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PS to PDF conversion using batch commands

1,690 views
Skip to first unread message

Antonio Ruiz

unread,
Jun 4, 2012, 7:21:40 AM6/4/12
to
Hi all,

i'm trying to convert postscript files to pdf using batch commands (ms-
dos) and ghostscript. I can print it if I write the file name in this
manner:

gsview32 "-sHP LaserJet 1300" c:\1.ps

but I need to print several files in this manner:

gsview32 "-sHP LaserJet 1300" c:\*-1.ps

where * is a different name each time. However, these instructions
doesn't work. I think that gsview doesn't understand a random file
*-1.ps. Is there a way to do what I want? Is it possible to convert
these .ps files to .pdf using batch command+ghostscript?

Thanks in advance. Best Regards,

Antonio Ruiz.

ken

unread,
Jun 4, 2012, 10:53:16 AM6/4/12
to
In article <24755102-2f0c-48ad-a2fb-64cc29678135
@b1g2000vbb.googlegroups.com>, aruiz...@gmail.com says...

> i'm trying to convert postscript files to pdf using batch commands
(ms-
> dos) and ghostscript. I can print it if I write the file name in this
> manner:

GSView is not Ghostscritp, I would start by using Ghostscritp
(gswin32c.exe)


> gsview32 "-sHP LaserJet 1300" c:\*-1.ps
>
> where * is a different name each time. However, these instructions
> doesn't work. I think that gsview doesn't understand a random file
> *-1.ps. Is there a way to do what I want? Is it possible to convert
> these .ps files to .pdf using batch command+ghostscript?

Yes, but not like that. Use the Shell command 'for', eg:

For %s in (*-1.ps) do gswin32c -sDEVICE=pdfwrite ..... %s

Antonio Ruiz

unread,
Jun 4, 2012, 4:04:46 PM6/4/12
to
On 4 jun, 16:53, ken <k...@spamcop.net> wrote:
> In article <24755102-2f0c-48ad-a2fb-64cc29678135
> @b1g2000vbb.googlegroups.com>, aruizbu...@gmail.com says...
>
>
>
> > i'm trying to convert postscript files to pdf using batch commands
> (ms-
> > dos) and ghostscript. I can print it if I write the file name in this
> > manner:
>
> GSView is not Ghostscritp, I would start by using Ghostscritp
> (gswin32c.exe)
>
> > gsview32 "-sHP LaserJet 1300" c:\*-1.ps
>
> > where * is a different name each time. However, these instructions
> > doesn't work. I think that gsview doesn't understand a random file
> > *-1.ps. Is there a way to do what I want? Is it possible to convert
> > these .ps files to .pdf using batch command+ghostscript?
>
> Yes, but not like that. Use the Shell command 'for', eg:
>
> For %s in (*-1.ps) do gswin32c -sDEVICE=pdfwrite ..... %s


Excuse me, I'm a beginner in postscript... :(
I'll try it tomorrow at work. Thank you very much, Ken!!!

ken

unread,
Jun 5, 2012, 2:47:48 AM6/5/12
to
In article <f1ab8b6f-5d81-4142-a924-86744beaa988
@j9g2000vbk.googlegroups.com>, aruiz...@gmail.com says...
> > Yes, but not like that. Use the Shell command 'for', eg:
> >
> > For %s in (*-1.ps) do gswin32c -sDEVICE=pdfwrite ..... %s
>
>
> Excuse me, I'm a beginner in postscript... :(
> I'll try it tomorrow at work. Thank you very much, Ken!!!

That's not PostScript, its command shell commands (batch file if you
want to describe it that way)


Ken

Antonio Ruiz

unread,
Jun 6, 2012, 7:15:18 AM6/6/12
to
On 5 jun, 08:47, ken <k...@spamcop.net> wrote:
> In article <f1ab8b6f-5d81-4142-a924-86744beaa988
> @j9g2000vbk.googlegroups.com>, aruizbu...@gmail.com says...
>
> > > Yes, but not like that. Use the Shell command 'for', eg:
>
> > > For %s in (*-1.ps) do gswin32c -sDEVICE=pdfwrite ..... %s
>
> > Excuse me, I'm a beginner in postscript... :(
> > I'll try it tomorrow at work. Thank you very much, Ken!!!
>
> That's not PostScript, its command shell commands (batch file if you
> want to describe it that way)
>
>                         Ken

This works in a batch (.bat) file: for %%s in (c:\*-1.ps) do gsview32
"-sHP LaserJet 1300" %%s

now, i'm thinking how can I convert my *-1.ps file to *-1.pdf

bugbear

unread,
Jun 7, 2012, 4:56:43 AM6/7/12
to

Peter Flynn

unread,
Jun 8, 2012, 3:25:45 PM6/8/12
to
Copy them all to a Unix system and type

$ for f in *-1.ps; do ps2pdf $f; done

The copy the results back.

///Peter

Antonio Ruiz

unread,
Jun 8, 2012, 5:48:09 PM6/8/12
to
now, we're working with FreeDist, a free PS to PDF conversor. We run
FreeDist using the same .bat file (under a windows-xp environment).
Therefore, problem solved!
Thanks to all.

cmwe...@gmail.com

unread,
Jun 28, 2013, 11:48:50 PM6/28/13
to
rem Set GhostScript and PDF directory parameters
@echo off
set GSWIN=C:\gs\gs9.07\
set /a count=0


for /f "delims=" %%F in ('dir %CD%\*.prn /b /o-n') do set file=%%F


SETLOCAL ENABLEDELAYEDEXPANSION
for %%F in ("%CD%\*.prn") do (

if !count! == 0 (
call gswin32c -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=merged.pdf -dBATCH %file%
set /a count+=1
) else (

IF NOT %%~nF.pdf==merged.pdf IF NOT %%~nF.pdf==merged1.pdf IF NOT %%~nF.pdf==%file% (
call gswin32c -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=merged1.pdf -dBATCH merged.pdf %%~nF.prn
del %%~nF.pdf
del merged.pdf
ren merged1.pdf merged.pdf
)
set /a count+=1
)
)

echo The no. of pdf files is !count!
gswin32c -q -dNODISPLAY -c "(merged.pdf) (r) file runpdfbegin pdfpagecount = quit" > tmpfile
set /p myvar= < tmpFile
del tmpFile
echo The no. pages in the pdf is !myvar!


if !count! == !myvar! (
GOTO:EOF
) else (
call gswin32c -o merged1.pdf -sDEVICE=pdfwrite -dFirstPage=2 merged.pdf
del merged.pdf
ren merged1.pdf merged.pdf
)
ENDLOCAL
0 new messages