cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Ghostscript batch question

BrianToussaint
19-Tanzanite

Ghostscript batch question

Hello,

I am tyring to use ghostscript and batch to create PDFs out of WF4. I can get it to work with just the name of the file. However, I would like to do more than that. I would like to be able to ask the user for input and then add that input to the file name. Basicaly I am asking the user for the revision of the drawing and then want to add it to the drawing. I have gotten it to ask for the revision and add rev to the end of the file name, but I cannot get it to add the input.

Any help will be appreciated.

Here is the code:

rem ** For trouble shooting, remark this line
ECHO OFF

rem ** Get the plot file name and location from the command line.
rem ** Use %* to get entire line for paths with spaces
set INNAME=%*

:revno
set REVNO=
set /P REVNO=Type in Revision of drawing:


rem ** Change the .ps to .pdf for the output.
rem ** Add the year month and day to the name, e.g., 2008-06-26
rem ** set OUTNAME=%INNAME:.ps=%-%date:~10,4%-%date:~4,2%-%date:~7,2%.pdf
set OUTNAME=%INNAME:.ps=rev%REVNO%,%.pdf
rem ** set OUTNAME=%INAME:.ps=%.pdf

rem ** Start Ghostscript, make sure that "C:\Program Files\gs\gs8.60\lib" is set in your path.
rem ** For NT this is setup in: Control Panel + System + Enviroment + path.
set PATH=%PATH%;"C:\Program files\gs\gs8.63\lib";"C:\Program Files\gs\gs8.63\bin"

rem ** Ghostscript can be on a central server, with a mapped drive
rem ** Use double quotes around every veriable to handel spaces in paths
call "ps2pdf" "%INNAME%" "%OUTNAME%"

rem ** Delete the original plot file.
del "%INNAME%"

rem ** Startup Acrobat Reader with the file. Your path must contain the path to AcroRD32.exe
rem ** typically that is something like this: C:\Program Files\Adobe\Reader 8.0\Reader
start " "Acrobat.exe" "%OUTNAME%"

rem ** For trouble shooting, remove the remark on this line
rem ** PAUSE

Thank you,

Brian Toussaint

CAD Administrator

Hoshizaki America


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
1 REPLY 1

I got one reply. Thank you for the ideas. I had hoped to keep it all within ghostscript.

The solution that I ended up with was different than the suggestions. I truncated the OUTNAME variable and then created one called OUTNAME1 that added the revision and .pdf. Here is the solution that I used:
rem ** truncates INNAME to no extension and adds rev
set OUTNAME=%INNAME:.ps=rev%
rem ** adds revision number and .pdf to file name
set OUTNAME1=%OUTNAME%%REVNO%.pdf

The one reply was this:
I would write a bat file or a visual basic app that prompts the user for the directory the files reside in.
Then have it copy the files to another dir and rename them as required by merging the user input with
the file name. You might be able to incorporate this into a web.link or jlink app that automatically grabs
the drawing revision from the drawings. Once the files have been copied to the gostscript directory and renamed then
have the jlink, weblink, or visual basic app launch the ghost script app and process the files.

Hope this gives you some ideas

Sincerely,
Brian
Top Tags