What is the command to convert a simulation.ps file with multiple pages to separate .pcx files using ghostscript on windows 7. I tried the following command:
cd c:\Program Files\gs\gs\9.06\bin
gswin32c -dNOPAUSE -sDEVICE=pcx24b –g1024x768 -sOutputFile=simulation%%04d.pcx simulation.ps
I got the following output:
GPL Ghostscript 9.06 (2012-08-08)
Copyright (c) 2012 Artifex Software, Inc. All Rights Reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimusSanL-Regu font from %rom%Resoruce/Font/NimbusSanL-Regu... 2637176 1249969 2756072 1473902 1 done.
There was no files created in the c:\Program Files\gs\gs\9.06\bin\ directory
Try it with just one '%' sign instead of 2. Other than that, your command line works for me (I substituted the golfer EPS file for your 'simlation.ps')
Related
I'm using GS to "compress" PDF with 2 clicks. I've added a context menu in windows register with abovementioned code.
For instance if I use it on test.pdf the output file will be test.pdf-compressed.pdf. It works, but I would like to get rid of extention in the filename. Is there any way to do so?
I've tryied to use cmd arguments, but it does not seem to work with the postscript.
C:\Program Files\gs\gs9.27\bin\gswin64c.exe -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -dCompatibilityLevel=1.4 -sOutputFile=%1%-compressed.pdf -c .setpdfwrite -f %1
This isn't a Ghostscript question. If you get the arguments correct then the parameters passed to Ghostscript will be correct and the output file will be what you want.
You haven't said what you've tried, so that makes it pretty hard to make suggestions. However you should be able to use %~dp1 and/or %~n1 instead of simply %1 to expand to just a path or file. There are other variations, typing "help for" at the Windows command line will give you more details.
Note as always that Ghostscript does not compress PDF files, by using -dPDFSETTINSG=/ebook you are producing a brand-new PDF file which has altered the content from the original (image will be downsampled for example).
Also the sequence -c .setpdfwrite -f has been redundant for years, you don't need it.
[EDIT]
This batch file demonstrates the use of the command shell variable expansion in a batch file
#ECHO OFF
ECHO Input file is %1
ECHO Input directory is %~dp1
\ghostpdl\debugbin\gswin32c -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=%~dp1\new.pdf %1
When saved as test.bat and then test d:\temp\input.ps the following output is generated:
Input file is d:\temp\input.ps
Input directory is d:\temp\
GPL Ghostscript GIT PRERELEASE 9.28 (2019-04-04)
Copyright (C) 2019 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
And a file new.pdf is created in the directory d:\temp
So the variable expansion works as expected, because it happens before the command line is executed.
If it still doesn't work for you, then you're going to have to provide more information. In your place I would start by removing the -dNOPAUSE and -dBATCH switches from the command line, at least that way you'll be able to see if Ghostscript is trying to tell you something.
I've clearly stumbled upon this posting a bit late.
However, I wanted to post my answer in case someone comes looking for a solution to a similar issue, in the future.
I started by creating a new Folder on my Desktop, titled "PDF", in which I placed the "test.pdf" File.
I then created a .BAT File, titled "CompressPDF.bat", to which I added the Script below.
This Script will Loop through and Compress Any/All .PDF Files, that are placed in the "PDF" Folder.
It then correctly appends the "-compressed.pdf" string to the File Name, thereby saving the "test.pdf" File as "test-compressed.pdf", per the request of the OP.
As you will Notice, I have Added the "PAUSE" Command at the very end of the Script.
This will keep the Window from Automatically Closing until you Press Any Key, which will allow you to review any Errors that may have arisen, during the compression process.
#echo off
cd "%USERPROFILE%\Desktop\PDF"
for %%f in (*.pdf) do (
gswin64c.exe -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="%%~nf-compressed.pdf" "%%f"
)
PAUSE
I hope this post is able to help others, who may be looking for an answer to a similar issue.
Please, feel free to response or to reach out to me, if anyone has any questions, as I am always happy to help.
I have a powershell script that is using 7zip to extract backup file from a particular folder. It was working before with rar files but the backup file compression changed from rar to zip. I was thinking the command used would work with out no changes but I am facing unexpected problems.
The command in use is
`7z e -y -i!Backups\TempFolder\t\* \TempFolder\t\
Backups\tempfolder\t\ folder has 2 zip files that were generated this morning. When I ran that command the output is
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Processing archive: \TempFolder\t\Admin_Backup.bak.zip
No files to process
Processing archive: \TempFolder\t\spector_Backup.bak.zip
No files to process
Archives: 2
Files: 0
Size: 0
Compressed: 206848564
Could someone tell me why the e command supplied with -y is not extracting the files ? Also, I thought the generated zip files were corrupted but I extracted manually fine.
You need to use the option -o for providing the output folder. Also, you don't need the option -i for the input files. Try this:
7z e -y Backups\TempFolder\t\* -o\TempFolder\t\
I am getting this below error when trying to extract SQL Server ISO file.
file cab1.cab already exists. Overwrite with
1033_ENU_LP\redist\VisualStudioShell\VSSetup\cab1.cab? (Y)es / (N)o /
(A)lways / (S)kip all / A(u)to rename all / (Q)uit?
When using with -aoa its exracting fine. But why I am getting this error? Replacing the files will cause any problems on the executables?
I found the answer.
When using the command
7z e <"filename">
it extracts all the files and files inside the subdirectories into the current working directory.
Solution to this is
7z x <"filename">
I was getting "can't allocate required memory" error in 7za command line tool in Windows 64bit and the solution was to use the 7zip 64bit installer and use the same command using the installed 7z.exe.
I guess 7za command line tool is 32bit and the file that I was trying to compress was 150GB which is too big and 7zip was trying to allocate more memory than 32bit supports.
Today I lost my whole Far Cry 3 save game suddenly. So now I want to backup it's save game folder automatically on a certain period of time using windows task scheduling.
I want to include date and time in archive file name.
Here is my command
C:\>"C:\Program Files\7-Zip\7z" a -r "D:\FC3\%DATE:~7,2%.%DATE:~4,2%.%DATE:~-4% %TIME% Backup".7z "C:\ProgramData\Orbit\46"
For formatting purpose, I followed this question on superuser
I am getting log when executing this command
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning
Creating archive D:\FC3\24.02.2013 17:52:10.62 Backup.7z
Error:
7-Zip cannot open file
D:\FC3\24.02.2013 17:52:10.62 Backup.7z
The filename, directory name, or volume label syntax is incorrect.
System error: Unspecified error
If I use a simple file name like "D:\abc". It would work.
Please help. Where I am going wrong..?
I got the point
File Names can not have :
I fixed the code by replacing colon with .
C:\>"C:\Program Files\7-Zip\7z" a -r "D:\FC3\%DATE:~7,2%.%DATE:~4,2%.%DATE:~-4% %TIME:~0,2%.%TIME:~3,2%.%TIME:~-5% Backup".7z "C:\ProgramData\Orbit\46"
I have the latest GPL Ghostscript v9.05 and I am running it on Win 32 bit systems. On my XP machine, both commands
ps2pdf -v -
and
rungs -v (used internally by TeXLive)
report of Ghostscript 9.05 being available as follows:
GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
On another Win 7 computer, the command
ps2pdf -v -
at the command line is not recognised as being a valid ps2pdfsyntax but rungs -v works fine.
I have read on the internet about setting temporary directories for Ghostscript here:
http://schlingel.bplaced.net/?p=54
and it says basically to edit the gssetgs.bat file in the lib folder of Ghostscript and add the lines:
set path=%ProgramFiles%\gs\gs9.02\lib;%ProgramFiles%\gs\gs9.02\bin;%windir%\SysWOW64
set TMP=%YOUR_TEMP%
set TEMP=%TMP%
This needs to be modified appropriately by replacing 9.02 with 9.05 in my case. Now on Win 7, how should the last two lines regarding the temporary folder be? Can I have for Set TMP as follows:
set TMP=%"C:\Users\hihi\AppData\Local\Temp"%
Is it the right syntax?
I have also put the tmp and temp variables in my Environment variables.
Update
A. Using ps2pdf, here is how I convert a PS to a PDF file on my Win 7 machine and I get an error:
C:\work\misc>ps2pdf -dNOSAFER -sDEVICE=pdfwrite -r720 -dCompatibilityLevel=1.5 -dUseFlateCompression=true -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -dEPSCrop "%1.ps" "%1.pdf"
Unknown device:
Unrecoverable error: undefined in .uninstallpagedevice
Operand stack:
defaultdevice
Note: the above command works fine on my Win XP machine!
B. Using gswin32c here is how I convert a PS to a PDF file on my Win 7 machine and this works:
C:\work\misc>gswin32c.exe -o "%1.pdf" -dNOSAFER -sDEVICE=pdfwrite -r720 dCompatibilityLevel=1.5 -dUseFlateCompression=true -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -dNumRenderingThreads=2 -c "60000000 setvmthreshold" -f -dEPSCrop "%1.ps"
GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusSanL-Regu font from %rom%Resource/Font/NimbusSanL-Regu... 2837152
1454727 4413848 3026018 1 done.
Loading Dingbats font from %rom%Resource/Font/Dingbats... 2837152 1510862 457461
6 3180865 1 done.
Loading NimbusSanL-Bold font from %rom%Resource/Font/NimbusSanL-Bold... 2857248
1553499 4655000 3251960 1 done.
Note: the above command also works fine on my Win XP machine
To summarise: I have problem with ps2pdf on my Win 7 machine.
New (May 09, 2012)
This is what I get when I rem the last two lines as Ken suggested:
C:\work\misc>ps2pdf -dNOSAFER -r720 -dCompatibilityLevel=1.5 -dUseFlateCompression=true -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -dEPSCrop "%1.ps" "%1.pdf"
Unrecoverable error: typecheck in .putdeviceprops
avoiding clean up
The temp folder has those temporary files you mentioned.
The contents of _.at:
-dCompatibilityLevel#1.4
-dNOSAFER
-r720
-dCompatibilityLevel
The contents of _.at2:
-q -P- -dSAFER -dNOPAUSE -dBATCH -sDEVICE#pdfwrite
-sOutputFile#-dUseFlateCompression
-dCompatibilityLevel#1.4
-dNOSAFER
-r720
-dCompatibilityLevel
-c .setpdfwrite -f1.5
Update May 11
Note: This is working fine now on my win 7 machine
C:\work\misc>ps2pdf -dNOSAFER -r720 -dCompatibilityLevel#1.5 -dUseFlateCompression#true -dMaxSubsetPct#100 -dSubsetFonts#true -dEmbedAllFonts#true -dEPSCrop "defense.ps" "defense.pdf"
avoiding clean up
The contents of _.at:
-dCompatibilityLevel#1.4
-dNOSAFER
-r720
-dCompatibilityLevel#1.5
-dUseFlateCompression#true
-dMaxSubsetPct#100
-dSubsetFonts#true
-dEmbedAllFonts#true
-dEPSCrop
The contents of _.at2:
-q -P- -dSAFER -dNOPAUSE -dBATCH -sDEVICE#pdfwrite
-sOutputFile#"defense.pdf"
-dCompatibilityLevel#1.4
-dNOSAFER
-r720
-dCompatibilityLevel#1.5
-dUseFlateCompression#true
-dMaxSubsetPct#100
-dSubsetFonts#true
-dEmbedAllFonts#true
-dEPSCrop
-c .setpdfwrite -f"defense.ps"
Thanks.
Far more likely than a temporary file problem is permissions on the directory where you are trying to write the destination file. The error message you quote occurs long before any temporary files are used, but is a very common error if you try to write to a directory which does not exist, or which the process has no write permission for.
First thing to do is post the actual gswin32 command line you are using.
The syntax you are querying is incorrect. %value% is a Windows scripting operation which says 'replace the stuff between the % signs by the named value'. So if I declare 'set VAL=c:/temp' Then I can say 'set NEWVAL=%VAL%/New' which will make NEWVAL 'c:/temp/new'. You can find more about windows scripting in the Windows help, or by a quick Google.
Given that 'ps2pdf' (which is a Windows script) can't be found on your Windows 7 machine (at least I assume that's what you mean by 'is not recognised as being a valid ps2pdf command') it does seem like you need to add the Ghostscript paths to your environment. Simply altering gssetgs.bat on its own will do nothing, you need to ensure that this script file is called from your autoexec.bat script, so that the additional environment settings are applied.
If you aren't sure what autoexec.bat is, or how to modify it, then again Google should help you pretty quickly.
Did you actually install Ghostscript, or simply copy it ?
Given that Ghostscript works correctly, the problem must be in the shell script 'ps2pdf', or more accurately some change in Windows 7 is causing the old script not to work.
This script is (unfortunately) rather more complex than I would like (I didn't write it). it actually uses about three different scripts to do the work. You really need to find out what is being sent to GS.
Probably the simplest way to do this is to edit 'ps2pdfxx.bat'. At the :end label you'll see 'rem Clean up' followed by two lines beginning 'if exist'. Put rem in front of those two. Add a line which says 'echo avoiding clean up' The end of the file should look like this:
:end
rem Clean up.
rem if exist "%TEMP%_.at" erase "%TEMP%_.at"
rem if exist "%TEMP%_.at"2 erase "%TEMP%_.at"2
echo avoiding clean up
Now run your command line (by the way you really don't need to put -sDEVICE= when using ps2pdf.....)
In your TEMP directory you should have files called _.at and possibly _.at2 which will contain the actual commands being sent to GS.
OK the file _.at is copied into the file .at2, and then.at2 is used as the list of arguments to Ghostscript. Commenting up the file you got:
---This line added by the batch file ps2pdfxx.bat
-q -P- -dSAFER -dNOPAUSE -dBATCH -sDEVICE#pdfwrite
---These lines come from _.at
-sOutputFile#-dUseFlateCompression
-dCompatibilityLevel#1.4
-dNOSAFER
-r720
-dCompatibilityLevel
--This line added by the batch file ps2pdfxx.bat
-c .setpdfwrite -f1.5
There are a number of problems with this:
-sOutputFile#-dUseFlateCompression
This in effect sets the output file to '-dUseFlateCompression'
-c .setpdfwrite -f1.5
I'm not completely sure what this will do. Either it will handle the -f properly and terminate the PostScript input, or it will ignore it as an unrecognised switch (probably the latter). The '1.5' ought to be the input filename, without that Ghostscript doesn't know which file to use..... Even if it did, it will try to write the output to a bogus filename.
To be honest I would suggest that, if you want to set all these switches, you simply invoke Ghostscript directly rather than trying to use the script. In fact I'd recommend that anyway, every time I look at these scripts I shudder more.
Almost everything that the ps2pdf script is doing is being overridden by your command line, or is not required in the first place.