How to execute shell command in DEVONthink Pro?

Hi guys,

I’m using DEVONthink Pro for a couple of months now and I know there is a way to automate tasks :slight_smile: The requirement on my side is: I have lot of documents which are smaller than the default size A4 (e.g. vouchers etc.). So my idea is to centre this documents on a A4 page automatically to get all documents A4’ed.

I get a CLI command working for that which uses gs but I have no clue how to integrate that into the DEVONthink Pro workflow :frowning: Anyone has a hint for me?

This works fine at command line:

gs -dPDFSETTINGS=/default -dBATCH -dNOPAUSE -dSAFER -sDEVICE=pdfwrite -sOutputFile=out.pdf -c “<< /Policies << /PageSize 3 >> /PageSize [595 842] /InputAttributes currentpagedevice /InputAttributes get mark exch {pop << /PageSize [595 842] >> } forall >> >> setpagedevice” -f in.pdf

Cheerio and thanks in advance,
Chris

The only option I can think of offhand is to wrap this in an Applescript “do script” command.

This is getting into really ancient DEVONthink-ology. There’s a script in Scripts > Execute named “Shell Script”. It dates from 2004, but still works as far as I can tell. It’s an odd script, because it can operate either stand alone, or it can be attached to a document and run by clicking the document.

Standalone: select a command line string (such as the one @ctp posted, above) in the body of a document, then execute the script.

Triggered mode: Select a document (plain text works best) whose body consists just of the command line string you want to execute. Open Tools > Show Info. Click “Select” next to the Script field. Navigate to “Shell Script” and click “Choose”. Now, whenever you select that document, the script will execute.

Dire Warning: there are minimal (mainly useless) warnings thrown off from the script. If your command line code causes OS X to format your system disk, then that’s what will happen. Be sure you know what you’re doing.

Thanks for the assist, korm. I completely missed that one. I’m going to have to look at that one.