Dropzone+Hazel+DTPO Inbox

Hi there.

I’m a longtime user of DTPO but never got into automation. Now that I have, some questions have come up as to how to leverage automation (AppleScript, perhaps?) to move a file or group of files from one group to another.

I’ve successfully been able to create a routine that allows me to use Dropzone to Move Files to a folder watched by Hazel (_to_devonthink) thanks to this post: 40tech.com/2017/03/09/put-a … -dropzone/

Hazel is then set up to run an embedded AppleScript to put the file in the Global Inbox database.

The AppleScript below has been modified from the sample provided in the above post and is working:

tell application id "com.devon-technologies.thinkpro2"
	set img_ib to get record at "@p:Inbox" in database
	"Inbox"
	import theFile to img_ib
end tell

My question is how can I modify the AppleScript to put the file/files into a specific group/folder in the Global Inbox database (or any other database for that matter).

Thank you in advance for the help.

–Shawn

Just change the get record at “…” parameter to the location of the group (something like “/path/to/myGroup”)

Hi guys!

I’m playing around with two scripts and I have made ONE script. The script is about saving all Safari tabs to a specific group in a database.

I used a script from Veritrope.com to save current Tab sets from Safari.

And the other script is from here.(Dropzone+Hazel+DTPO Inbox) to save it to specific group in a database.

From the script from Veritrope I just changed the “in current group” to the group I want, which is “in /path/to/November 2018” and works fine, it goest to that group.

The problem is that a pop up comes and I have to choose “ok” or “cancel”

How do I bypass that pop up? And straight to the group? like the script from Hazel?

The script 1 below is from Hazel that saves files to a specific group in DevonThink.

Script 1:


tell application id “com.devon-technologies.thinkpro2”
set img_ib to get record at “/path/to/November 2018” in database
“Inbox URL”
import theFile to img_ib
end tell


Script 2:



From Veritrope.com. URL Script.
*)

(* 
======================================
// MAIN PROGRAM 
======================================
*)

-- PREPARE THE LIST
set urlList to {}
set the date_stamp to ((the current date) as string)
set NoteTitle to "URL List from Safari Tabs on " & the date_stamp

--PROCESS TABS OF FRONTMOST SAFARI WINDOW
tell application "Safari"
activate
set safariWindow to the front window
set successCount to 0
set tabCount to (count of (tabs of safariWindow))

repeat with w in safariWindow
--GET TAB INFORMATION	
try
repeat with t in (tabs of w)
set TabTitle to (name of t)
set TabURL to (URL of t)
set TabInfo to ("<a href=\"" & TabURL & "\">" & TabTitle & "</a><br/>")

--COPY TAB INFO TO END OF LIST	
copy TabInfo to the end of urlList

--INCREMENT SUCCESS COUNT
set successCount to (successCount + 1)

end repeat
end try
end repeat
end tell

--CONVERT LIST TO TEXT
set old_delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set url_list to urlList as text
set AppleScript's text item delimiters to old_delim

--MAKE THE ITEM IN DEVONthink Pro	
tell application "DEVONthink Pro"
create record with {type:html, source:url_list, name:NoteTitle} in "/path/to/November 2018"
end tell

--NOTIFY RESULTS
my notification_Center(successCount, tabCount)

(* 
======================================
// NOTIFICATION SUBROUTINE
======================================
*)

--NOTIFICATION CENTER
on notification_Center(successCount, itemNum)
set Plural_Test to (successCount) as number

if Plural_Test is -1 then
display notification "No Tabs Exported!" with title "Send Safari Tabs to DEVONthink Pro" subtitle "◸ Veritrope.com"

else if Plural_Test is 0 then
display notification "No Tabs Exported!" with title "Send Safari Tabs to DEVONthink Pro" subtitle "◸ Veritrope.com"

else if Plural_Test is equal to 1 then
display notification "Successfully Exported " & itemNum & ¬
" Tab to DEVONthink Pro" with title "Send Safari Tabs to DEVONthink Pro" subtitle "◸ Veritrope.com"

else if Plural_Test is greater than 1 then
display notification "Successfully Exported " & itemNum & ¬
" Tabs to DEVONthink Pro" with title "Send Safari Tabs to DEVONthink Pro" subtitle "◸ Veritrope.com"
end if

set itemNum to "0"
delay 1
end notification_Center

Modifying other peoples’ code is not an easy thing, especially when the approach is dinstinctly different than your own.

This is my take on the Safari tab script, which you should be able to modify to your taste quite easily…

tell application "Safari"
	if exists window 1 then
		set itms to {}
		set tabList to {URL, name} of (tabs of window 1)
		repeat with itm from 1 to (count tabs of window 1)
			if (item itm of item 1 of tabList) begins with "http" then
				copy ("<a href=\"" & (item itm of item 1 of tabList) & "\">" & (item itm of item 2 of tabList) & "</a><br/>") to end of itms
			end if
		end repeat
		my dtnote(itms)
	else
		display alert "No Safari windows open"
	end if
end tell

on dtnote(itms)
	tell application id "DNtp"
		create record with {name:"safari tabs", type:html, source:(itms as string)} in incoming group
	end tell
end dtnote
1 Like

I don’t think your script is working as expected because “/path/to/November2018” is probably not what your directory structure looks like. The “/path/to/” portion is meant to be replaced by the actual path in which your “November 2018” group sits

Thank you. I’m actually new to scripting. Sorry I know you guys are busy. Thanks for taking the time.

The script that you posted sends the url HTML to the main Inbox.

If I want it to send it to a Database “URL” (name of the database) and the folder name is “November 2018”.

What do I need to change? I tried replacing the “incoming group” with “November 2018” but it doesn’t work. And I tried many other things but it didn’t work. Sorry if this are basic things.

Please let me know. Thank you :slight_smile:

You said you already have the first script working with this line of code in it…

which I also assumed you have replaced the location with the proper path.

For example…

on dtnote(itms)
	tell application id "DNtp"
		set dest to get record at "Inbox/Arabic" in database "newDB"
		create record with {name:"safari tabs", type:html, source:(itms as string)} in dest
	end tell
end dtnote

Thank you again. I will give it a try again over the weekend, see how things turn out.

Thanks :slight_smile:

You’re welcome.