0

If I have some .eps files e.g pic00.eps, pic01.eps, ... Then on Linux I convert them to .png files by running the command:

gs -dSAFER -dBATCH -dNOPAUSE -dEPSCrop -sDEVICE=png16m -r600 -sOutputFile=pic%02d.png pic*.eps

I've just tried on Windows 10 (with gswin64c instead of gs) and that doesn't work. The error says that:

pic*.eps is an undefined filename.

What is the command on Windows?

1

1 Answer 1

1

This works in Linux because your shell (probably bash) is expanding the *.eps to a full list of epses before ghostscript gets anything. In Windows, the shell won't do that for you.

In Powershell, I'd do this:

$names = (dir *.eps).name
gswin64c -dSAFER -dBATCH -dNOPAUSE -dEPSCrop -sDEVICE=png16m -r600 '-sOutputFile=pic%02d.png' $names

I've also single-quoted the -sOutputFile parameter in case PowerShell were to have trouble with the percent sign.

In cmd batch, I'd do this:

for %%i in (*.eps) do (
   gswin64c -dSAFER -dBATCH -dNOPAUSE -dEPSCrop -sDEVICE=png16m -r600 "-sOutputFile=%%i.pic%02d.png" %%i
)

This differs from what Linux and Powershell will do, in that each EPS will trigger a separate ghostscript execution. This is usually okay; using one EPS as a preamble for another is rather unusual.

I also prefixed the PNG filename with the eps name, because the page counter is going to reset for each EPS file, and you don't want pic01.png from the first EPS to get clobbered by the second EPS.

1
  • Thanks. Meanwhile I did my conversions with a R script which launches the command for each single file, in a loop. I'll try your solutions next time. Commented Oct 19, 2021 at 19:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .