in reply to Running an external GUI program

What sort of compression are you talking about, and why does it need to be done with a GUI-based tool? If you can be flexible about the style of compression you want to do, you could just do something on the shell command-line:
# simple case: compress all pdf files in current directory: gzip *.pdf # recursive-search case: compress all files under some path: find some/path -name '*.pdf' -print0 | xargs -0 gzip
Or, if you look up the help/manual on the command that you are currently using (whatever that is), you might find out whether it accepts a "batch-mode" or "non-interactive" option as a command-line flag.

(The worst thing about GUI apps that perform basic operations is that they are not suitable for doing batch processing.)