Cool .. now I just need to automate it in my plotting script
Please post how you automate, as I couldn't figure it out.
I found a way to combine all the pdf's in one directory into one pdf with ghostscript. You have to enable 'Delayed environment Variable Expansion' in the registry, but that is explained in the batch file code posted. I couldn't figure out how to do it at run time. They said to start a new command window with the /v:on statement, but I didn't know how to do that unless I have one batch open a new command window with the switch on, and then call another batch file to execute the code. I'm welcomed to suggestions.
@echo off
:: The ! syntax is needed to cause the environment variable to
:: be evaluated every time it's referenced instead of only at
:: the beginning of the statement. This is known as Delayed
:: Environment Variable Expansion (catchy name, I know). This is
:: NOT turned on by default.
:: To turn on Delayed Environment Variable Expansion for this
:: just script, run cmd with the /v:on switch. To set Delayed
:: Environment Variable Expansion on permanently for a given
:: user on a machine, create this REG_DWORD value and set it to 1:
:: HKEY_CURRENT_USER\Software\Microsoft\Command Processor\DelayedExpansion
:: To set this as the default for all users on a given machine,
:: use this key instead:
:: HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\DelayedExpansion
:: http://aspn.activestate.com/ASPN/Mail/Message/activeperl/3002204
echo.
set list=
for /F "delims=" %%i in ('dir *.pdf /b /od') do set list=!list! %%i
"c:\gs\gs8.54\bin\gswin32c" -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=allfiles.pdf %list%
echo Done!
Here is code to create pdf of all the .plt's in the directory, and combine them into one pdf.
@echo off
:: process all the .plt files in this directory to create them as pdf files,
:: then add them all into one pdf file named "AllFiles.pdf"
:: The ! syntax is needed to cause the environment variable to
:: be evaluated every time it's referenced instead of only at
:: the beginning of the statement. This is known as Delayed
:: Environment Variable Expansion (catchy name, I know). This is
:: NOT turned on by default.
:: To turn on Delayed Environment Variable Expansion for this
:: just script, run cmd with the /v:on switch. To set Delayed
:: Environment Variable Expansion on permanently for a given
:: user on a machine, create this REG_DWORD value and set it to 1:
:: HKEY_CURRENT_USER\Software\Microsoft\Command Processor\DelayedExpansion
:: To set this as the default for all users on a given machine,
:: use this key instead:
:: HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\DelayedExpansion
:: http://aspn.activestate.com/ASPN/Mail/Message/activeperl/3002204
echo.
for %%f in (*.plt) do "c:\gs\gs8.54\bin\gswin32c" -dSAFER -dBATCH -dNOPAUSE -sOutputFile="%%~nf.pdf" -sDEVICE=pdfwrite -c "<</Orientation 1>> setpagedevice" -f "%%f"
set list=
for /F "delims=" %%i in ('dir *.pdf /b /od') do set list=!list! %%i
"c:\gs\gs8.54\bin\gswin32c" -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=AllFiles.pdf %list%
echo Done!
Edit: If you want to delete the pdf files used to create the main pdf, then you can add this line right after you create the main pdf ( the blank line before 'echo Done!' ).
for %%f in ( %list% ) do del %%f