0

I'm trying to adapt this script into a drag and drop .bat file for Windows. The script itself works perfectly fine through the Command Prompt, but what I've tried has resulted in a blank output file. This is my first attempt at making a .bat file so any insight is appreciated!

@echo off
cd C:\Program Files\gs\gs9.26\bin
gswin64c.exe -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile="%~1"_sm.pdf "%~1".pdf
pause
exit

EDIT: Thanks guys, I've used your suggestions to make a .bat that works as intended!

@echo off
"C:\Program Files\gs\gs9.26\bin\gswin64c.exe" -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile="%~dp1%~n1_sm.pdf" "%~1"
pause
exit
nikis
  • 1
  • 1

1 Answers1

-1
@echo off
"C:\Program Files\gs\gs9.26\bin\gswin64c.exe" -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile="%~dp1%~n1_sm.pdf" "%~1"
pause
exit
nikis
  • 1
  • 1
  • Just take account that your code only uses `%1`, which means that you should only use the script to drag and drop onto. If you decide to use it otherwise, please make sure that your input file is doublequoted if it contains any one of a few different characters. The drop method automatically includes the doublequotes if needed. – Compo Nov 11 '19 at 02:10