Applescript importer to DevonThink Pro

I apologize if the answer to this question lies somewhere on the site.
I'm an avid user of DevonTHINK Pro as a method of tracking research. This involves downloading a lot of pdfs and importing them into a database.
I use a central download folder called "Inbox" in my home folder. I've already set Hazel to do the appropriate things to download archives, dmgs, music files, etc. I have an applescript that will import pdfs to a specific DevonTHINK Pro database behind the scenes.
The problem is that not every pdf that I download should go into this database. So I tried to make an applescript that prompts me when it's loaded, asking me whether or not the pdf should be added to DevontTHINK. The script works fine outside of a hazelprocessfile script, but throws an generic applescript error when used with Hazel. I've attached the code below.
Is this an issue with Hazel not wanting to wait for an applescript to complete? Thanks for your help.
I'm an avid user of DevonTHINK Pro as a method of tracking research. This involves downloading a lot of pdfs and importing them into a database.
I use a central download folder called "Inbox" in my home folder. I've already set Hazel to do the appropriate things to download archives, dmgs, music files, etc. I have an applescript that will import pdfs to a specific DevonTHINK Pro database behind the scenes.
The problem is that not every pdf that I download should go into this database. So I tried to make an applescript that prompts me when it's loaded, asking me whether or not the pdf should be added to DevontTHINK. The script works fine outside of a hazelprocessfile script, but throws an generic applescript error when used with Hazel. I've attached the code below.
Is this an issue with Hazel not wanting to wait for an applescript to complete? Thanks for your help.
- Code: Select all
on hazelProcessfile(addedFile)
--on run
set theFile to addedFile as alias
set addedInfo to info for theFile
set addedStr to name of addedInfo as string
set theQuestion to display dialog "Do you want to add " & addedStr & " to ∂Research?" buttons {"Yes", "No"} default button "No" giving up after 10 with icon 1
set theAnswer to button returned of theQuestion
if theAnswer is "No" then
return
else
try
tell application "DEVONthink Pro"
launch
open database "/Users/username/Documents/Research/∂Research.dtBase"
tell application "System Events" to set visible of process "DEVONthink Pro" to false
end tell
try
set thePath to addedFile as text
if thePath does not end with ".download:" then
tell application "DEVONthink Pro"
if exists incoming group then
import thePath to incoming group
else
import thePath
end if
end tell
--tell application "Finder" to move addedFile to trash
end if
end try
end try
end if
--end run
end hazelProcessfile