Script (applescript/JS) to send a file from Hazel to a specific devonthink group based on uuid?

hi all, I originally replied to an old thread

https://discourse.devontechnologies.com/t/import-from-hazel-to-various-groups-javascript/55635/13

yet it seemed the OP suggested this wasnt exactly relevant im posting a new thread on this

i am wondering if anyone has done something like this in the past and may be willing to share his script? im trying to have a last step in hazel that will directly send a matched and then proccesed file to a specific devonthink group based on uuid.

thanks so much in advance

Z

I use the following - your choice as to whether to use group name or UUID – just comment out (or delete) whichever you aren’t using:

	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 3") then
		tell application id "DNtp" to activate
	end if
end tell

-- Import the file.
tell application id "DNtp"
	--set img_ib to get record at "/Investments" in database "FileCabinet"
	set img_ib to get record with uuid "893B5B25-C929-4659-BA14-E6345B53196A"
	import theFile to img_ib
end tell

I’m sorry if this response is not helpful to you but I thought it might be worth mentioning the way I prefer to use Hazel with DEVONthink.

I use Hazel simply to route files to the DEVONthink inbox (so that they’re then automatically picked up by DEVONthink) and then rely on various smart rules in DEVONthink automatically to place the relevant file in the appropriate group in DEVONthink. I do find that works well for me but appreciate it may not for you.

Stephen

5 Likes