Automator workflow to split PDF

automator

I have an automator workflow, that is supposed to take a PDF from Hazel, split it into it's single pages and store the new PDFs one level above the input file. The output folder of the single page PDFs should depend on the input file.

Link to workflow in Dropbox

The first action is only for debugging purposes and doesn't contain a file in the saved version.

The last action claims to finish successfully, but it doesn't write anything. Or least I can't find any PDFs where I'd expect them.

When I set the target of the split PDF action to a preselected, fixed folder it works. But then the output location won't be determined by the input file.

How to get it to do what I want?

P.S.

Just found this similar issue (thanks to the issue suggestion bar on the right). I'll try that Apple script over there later, maybe the presentation of my folder isn't as the action would like it

Automator: extract PDF text and save in current directory

Best Answer

An adaptation of the code from the above mentioned thread

on run {input, parameters}
    tell application "System Events"
        set thePath to POSIX path of (container of container of (item 1 of input))
    end tell
    return thePath
end run

worked like a charm.

So I guess, the problem as in the presentation of the folder. While the "Set Variable" action can deal with a finder folder object and preview it correctly, the split PDF action apparently can't.