Questions about opening files on Alfred

As I said, I don’t run Alfred.

From what I gather, you need the Powerpack purchase to create a workflow. I believe the workflows have a node for running AppleScripts.

1 Like

Okay, got it. Very lucky to have met you. Have a nice day. :blush:

Here’s how a blank Workflow is created in Alfred:

  • Make sure to select the Workflows tab at the upper left corner
  • Click the + at the bottom and Blank Workflow

Here’s how an AppleScript action is created:

  • Make sure so have the focus on the Workflow content (not on the Workflow in the sidebar)
  • Contextual menu > Actions > Run Script:

  • In Alfred’s script editor window:

    • Open the Language dropdown and select /usr/bin/osascript (AS)
    • Open the dropdown to the right and select with input as {query}

Your Run Script action should look like this:

"{query}" is the input that the script gets from Alfred.

How you like to input a DEVONthink Reference URL into Alfred is up to you (at the moment I can’t imagine a way that would make sense).

Visit the Alfred forum for Alfred questions.

Thank you for your patience and detailed guidance! :heart:

I followed your steps to create the exact same workflow, but I still can’t get it to work. Do I need to create other steps in that workflow?

If you have a ready-made workflow that can be implemented, can you forward it to share? Thanks again!

Of course. The script needs some input:

But that’s not related to DEVONthink. Did you ask in the Alfred Forum?

See, for example, this post on the Alfred forums, and the linked workflow (which I use from time to time).

Stephen

Out of curiosity: Could you also write
if the Path = "" or thePath ends with "/"
since “/” in Unix is equivalent to “:” in HPFS…?
Is this check meant to prevent using an indexed folder?

Yes

Yes, this would work in DEVONthink. But some apps don’t return a folder’s POSIX path with a trailing slash while others do. This makes it impossible to reliably tell from a POSIX path whether it’s a folder’s or a file’s path. A folder’s HFS path always ends with : so this can be used to tell the difference.

Tx. It’s always amazing how complicated apparently simple things can become :wink:

Personally, I’d rather go for something like POSIX file thePath is a folder, though. If that’s at all possible, of course. Can a path of a record in DT even be empty?

Update I found this one

tell application "System Events"
if anItem is package folder or kind of anItem is "Folder" or kind of anItem is "Volume" then
…
end if

where anItem is apparently an alias of a file. Definitely not simpler than your approach.

Thank you for the recommendation. But this doesn’t seem to work for entering DT’s URL in Alfred. :exploding_head:

Does this seem like something that can’t be fixed? :face_with_monocle:

Sorry - it was the best general Alfred DT workflow I could find.

Stephen

It doesn’t matter, very happy to communicate with you. :rofl:

I previously forgot to ask this: Where do you get these DEVONthink links from?

I ask because I can’t imagine a scenario where I would have a plain text DEVONthink link and wanted to open its file in another app.

So what’s the scenario?

I bet you didn’t tell him that someone already wrote an AppleScript to open the file …

The problem of opening is solved. Your problem is that you don’t know how to tell Alfred what it should process. You need to find a way to deliver Alfred your input. Without input no workflow.

I often use a software called Hook (https://hookproductivity.com) to get DT’s file links and link two or more files in both directions, the trouble is that some software does not support url scheme, so I can only write down DEVONthink links to quickly open the relevant files.

I would 100% like to be able to process PDFs directly in DT, but unfortunately I need to process a lot of PDFs that contain Chinese, and if I do it internally in DT (e.g. highlighting or notes), all the Chinese in the PDF will be garbled (according to the official response from DT, this seems to be due to the PDFkit framework of macOS) and cannot be fixed by DT)

You are right, I will add to him. :grimacing:

Try this in Alfred

In the Workflow you created:

  • Contextual menu > Triggers > Fallback Search
  • Enter a meaningful title, e.g. “Open DEVONthink link with default app”
  • Connect the new trigger with the previously created Run Script action by dragging from its right side onto the Run Script action

On Alfred’s left side:

  • Select the Features tab (above Workflows)

In the sidebar:

  • Select Default Results

In the main area:

  • Click Setup fallback results

In the new window:

  • Click the + at the bottom
  • Select Workflow Trigger
  • Select the title you’ve chosen, e.g. “Open DEVONthink link with default app”
  • If there were already fallback searches you might want to drag your new fall back search to the top of the list for easier access.

Done!

Now when you invoke Alfred and paste a DEVONthink link you should be able to select the workflow that will open files in their default app.

Nice!!! It works perfectly! You’re so amazing!! :100: :wine_glass:

1 Like

Great!

If you want a nicer icon:

  • Go back to the Workflow
  • Select it in the sidebar
  • Contextual menu > Edit Details
  • Invoke Alfred and search for e.g. “DEVONthink”
  • Drag the result onto the Alfred preference’s window, where it says “Drop Workflow icon here”