Automator command line: “Unable to open workflow”

automator

I created a workflow in Automator consisting of a single action, "Convert Format of Word Documents" (provided by Microsoft Word). I saved this in ~/Documents/convert_word_to_pdf.app. I can run it by dragging a word file over this app, and it will generate a PDF for me. However, I can't figure out how to run it through the command line. I tried running automator convert_word_to_pdf.app foo.docx and I get Unable to open workflow.. I also tried convert_word_to_pdf and convert_word_to_pdf/document.wflow as arguments to automator, with the same results. What am I missing here?

Best Answer

Use -i:

automator -i foo.docx ~/Documents/convert_word_to_pdf.app

Or if there are multiple arguments:

printf %s\\n foo.docx bar.docx|automator -i - ~/Documents/convert_word_to_pdf.app

See the man page:

SYNOPSIS
     automator [-v] [-i input] [-D name=value ...] workflow

DESCRIPTION
     automator runs the specified workflow.  To create or edit a workflow, use
     the Automator application.

     The following options are available:

     -D name=value
              Set variable name to value for this run of workflow.

     -i input
              Set input as the input to workflow If input is - then the con-
              tents of standard input is used.  The newline character (\n) is
              the delimiter for multiple strings.

     -v       Run in verbose mode.