I need an AppleScript or a workflow that can be used with Hazel to import a file from a specified folder (specified maybe in Hazel) into a particular DTPO database and then delete it from the folder.
The idea is that any file sent to a Dropbox folder will cause Hazel to run a script that will send that file to the DTPO database.
Heaven forbid that I should poke around in the internals.
I want a share from iOS that just goes to DTPO. I was trying circuitously. Thing is, if I use any share sheet in iOS the iOS app has to be opened, too, to send it to a Dropbox-synced database. I wanted to send and forget, then see it on macOS.
DTPO doesn’t do as well as Keep It in this regard.
… includes a Hazel script that imports to a group whether its database is open or not. Can’t that be applied to a Finder selection using an Automator workflow ?
I was looking for a way to create a service from an Automator workflow which sends files to a group, to which I could set a keyboard shortcut.
I know there’s a bundled service in DTPO that sends files to the global inbox that I could use for this, but I wanted rather to send files to a specific group - and to do that whether the group’s database is open or not - or indeed whether DTPO is open or not.
That’s sort of what the script for the Hazel rule in that other thread does, only it’s not set up to be used as an Automator service for selecting files in the Finder. I thought maybe it could be adapted so that it could be.
tell application "Finder"
set itemlist to the selection
set theFile to (item 1 of itemlist) as alias
set _path to (the POSIX path of theFile as string)
set {_name, _extension} to {name, name extension} of theFile
-- optional: hide extension in Finder
set extension hidden of theFile to true
-- optional: remove extension for DEVONthink displays
set _name to text 1 thru -((count _extension) + 2) of _name
set _extension to "." & _extension
end tell
-- Launch DEVONthink if it isn't already open.
tell application "System Events"
if not (exists process "DEVONthink Pro Office") then
tell application id "com.devon-technologies.thinkpro2" to activate
end if
end tell
-- Import the file.
tell application id "com.devon-technologies.thinkpro2"
set theGroup to get record with uuid "INSERT_UUID_HERE"
-- choose one option, Index or Import, comment out the other
set theImport to import _path name _name to theGroup
-- set theIndex to indicate _path to theGroup
end tell
This can be used to place in an Automator worflow and then used as a service to which a keyboard shortcut can be assigned.
If I close the target database, quit DTPO, and then use that service on a file on the desktop, DTPO opens, the target database opens, and the file is added.
I just tested it again. It works.
It doesn’t delete the file - that’s left on the desktop or wherever, but it’s copied into the right database.
Just to be clear - this is no longer using Hazel … this is just using that script in an Automator workflow saved as a service, and evoked via a contextual menu click on a file (which can have a keyboard shortcut linked to it).