I use this script (from here) in order to reduce the size of a pdf file:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook \ -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
I have added this within a Dolphin action (service menu) with the line:
Exec=bash -c 'pdf=$(gs -dQUIET -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -sOutputFile=ebook.pdf "%u"); kdialog --title "Shrink" --msgbox "Done! $pdf";';
I would like the output file name to be automatically based on that of the input file, something like: input_xxx
.
f="%u"; pdf=$(gs ... -sOutputFile="${f%.pdf}_xxx}" "$f"); ...
– steeldriver Aug 25 '21 at 16:33"${f%.pdf}_xxx}"
, it should be"${f%.pdf}_xxx"
.) – cipricus Aug 25 '21 at 22:50"${f%.pdf}_xxx.pdf"
for my specific script. – cipricus Aug 25 '21 at 23:26