How to tell an Automator action, that the source path of a document should also be the destination path

applescriptautomatorpath

I'm using the Automator action "Convert to PDF" from ABBYY FineReader Pro. It just does OCR recognition on a given file and saves the output to a new PDF.

It looks like this:

abbyy-finereader-automator-action

The issue I'm having is the output folder ("Ausgabe speichern in"). I want to tell Automator, that the full path of the input file is also the desired path of the output file (nice to have: and appends "-ocr" to the filename).

I already found out, that this could be done with the AppleScript snippet, that you see on the bottom of the screenshot. Unfortunately, the files will end up in /Applications, because the ABBYY app is in there and so the variable isn't being interpreted as I wanted it to be.

Any insights and hints will be highly appreciated.

Best Answer

Okay, I downloaded the ABBYY_FineReader_Pro_ESD.dmg file from abbyy.com and installed it, then opened it to look at the help file for use with Automator. It didn't have much information so I checked the link in the help file back at abbyy.com and while it had some additional info, it did't have what I was looking for. Namely, documentation on programmatically setting "Output filename:" to a variable, like can be done with "Save output to:" setting it to a variable.

The following is an example of an Automator workflow, saved as a Service, to take a selected Image file in Finder and convert it to and editable PDF document. You can see in the image below what settings are relevant. Note that the only option in the Variable Options for the current_path variable only has a Name: field, no Script field. And while the image is taken in OS X 10.8.5 nonetheless I tested it in macOS 10.12 and Automator doesn't show Variable Options as in your picture. (So how did you get it like that?)

enter image description here

I set "Save output to:" by drag and drop the current_path variable onto it and then saved the Service. It important that you don't run the Service from within Automator because if done from Automator it changes "Save output to:" the containing folder's path and doesn't reset like it does automatically when it run as a Service from Finder.