Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
pumrelOffline
Post subject: Script for reducing pdf using gs  PostPosted: 08.12.2010, 18:25



Joined: 2010-09-14
Posts: 117
Location: Czech Republic
Status: Offline
Hello everybody,
I don't know anything about scripting in Linux (or any other OS Smile ), but I love this command, that I use a lot:

      Code:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf


and I just wanted to ask someone kind here: Is it possible to make this command into a script, which would reduce the size of all pdfs in a folder? Smile Please.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
bfreeOffline
Post subject: RE: Script for reducing pdf using gs  PostPosted: 08.12.2010, 19:15
Team Member


Joined: 2010-08-26
Posts: 251

Status: Offline
Here's a quick one only trivially tested. Save it in a file (say called pdfdir2ebook), make it executable (chmod +x pdf2ebook) and run it as something like:
      Code:
./pdfdir2ebook /path/to/dir/with/pdf

If it finds a something.pdf in /path/to/dir/with/pdf it will name the converted copy as something.ebook.pdf in the same directory.
      Code:

#!/bin/sh
if [ -d "$1" ]; then
  for orig in $1/*.pdf ; do
    ebook="${orig%%.pdf}.ebook.pdf"
    gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=${ebook} ${orig}
  done
else
  echo "You must supply the name of a directory as the first argument"
fi
 
 View user's profile Send private message  
Reply with quote Back to top
pumrelOffline
Post subject: RE: Script for reducing pdf using gs  PostPosted: 08.12.2010, 19:22



Joined: 2010-09-14
Posts: 117
Location: Czech Republic
Status: Offline
It works flawlessly Smile Thank you very much. You're very kind Wink

_________________
Petr
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 12 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by Zafenio