Scripts to Apply & Sync a DEVONthink “Hook” tag — and More DEVONthink Goodies

Here are some potentially useful additional scripts for using Hook and DEVONthink together.

Synchronize “Hook” tag for DEVONthink items

Hook users have told us on the Hook Productivity Forum that they would be handy to be able to tell at a glance whether an item in DEVONthink 3 has a Hook link.

The script below does that.

-- remove "Hook" tag from every record item in DEVONthink
tell application id "DNtp"
    set recs to lookup records with tags {"Hook"}
    repeat with itemRec in recs
        set oldTags to tags of itemRec
        set newTags to {}
        repeat with t in oldTags
            set unwrappedTag to "" & t
            if unwrappedTag is not equal to "Hook" then
                set newTags to newTags & t
            end if
        end repeat
        set tags of itemRec to newTags
    end repeat
end tell

-- add "Hook" tag to every record item which has hooked links to other items
tell application "Hook"
    set addrs to address of (every bookmark whose address begins with "x-devonthink-item://" and hooked bookmarks is not equal to {})
end tell
tell application id "DNtp"
    set AppleScript's text item delimiters to "x-devonthink-item://"
    repeat with addr in addrs
        set itemID to text item 2 of addr
        delay 0.5
        set itemRec to (get record with uuid itemID)
        if itemRec exists then
            if tags of itemRec does not contain "Hook" then
                set tags of itemRec to tags of itemRec & "Hook"
            end if
        end if
    end repeat
end tell

Basically this script goes through DEVONthink and removes the “Hook” tag from every item (in case there are tagged items which don’t have links anymore) and then it goes through Hook and finds every DEVONthink bookmark with linked items and adds a “Hook” tag to it in DEVONthink.

This just adds a tag. It doesn’t affect the icon or add any visual affordance, but maybe there’s some way for users to do that themselves for items with a given tag.

This is meant to be scheduled to run regularly, in launchd or whatever service user prefers.

More information about Hook integration with DEVONthink

Additional integration scripts are accessible from:

Hook Productivity App Newsletter

Sign-up to receive emails about Hook productivity app. Our emails sometimes include coupons for discounts on great Hook-linkable apps made by other developers.

 Marketing permission: I give my consent to to be in touch with me via email using the information I have provided in this form for the purpose of news, updates and marketing.

What to expect: If you wish to withdraw your consent and stop hearing from us, simply click the unsubscribe link at the bottom of every email we send or contact us at We value and respect your personal data and privacy. To view our privacy policy, please visit our website. By submitting this form, you agree that we may process your information in accordance with these terms.