Q:

PDF to PNG ghostscript Batch file issue

I am trying to drag a pdf onto a batch file which will then convert the pdf to a png, in the same directory. It all works well for a single page pdf, I get the right conversion to png format, the problem is when I am converting a pdf with multiple pages. The output says "Processing pages 1, 2, 3 etc... But what I end up with is only the first page of the pdf. Could anyone steer me in the right direction, I would be much appreciated.
I have created a batch file with the code below. Thank's in advance.
path=%PATH%;C:\Program Files (x86)\gs\gs9.20\bin\
cd %~dp1
gswin32c.exe -sDEVICE=pngalpha -sCompression=lzw -r300x300 -dBATCH -sOutputFile=%1.png %1

A:

You have to use %d as part of the output filename to specify the pattern for the page number in the pngs. -sOutputFile=%1_%%d.png in that case.

