There must be a better way.

That would be awesome. Or even if there were a way for Hazel to drop things into the right place without requiring that DT be open at the time.

Not a good idea, to insert files into a database without proper capture by DEVONthink.

Such files would not have been indexed for text content, and won’t be available until Tools > Verify & Repair has been run, to identify them as Orphan files requiring proper filing.

Bill is 100% correct, when importing documents into a database. However, Hazel works perfectly to move documents into folders that are indexed in the DEVONthink database. I do it all the time-just one of the reasons why I index all of my databases rather than import.

I agree. Which is why I’d love an Applescript/Automator way to add items to the Sorter, so that Hazel could run, and then submit items in a way for DT to capture on startup.

Have you had a look at the folder actions that Devonthink ships with. I have just discovered them but there might be something useful along the lines you are thinking that you can do with them


I have. They’re pretty useful, as are the automator actions that are shipped, but they don’t quite fit my needs.

I’ve got about ten databases or so, and I usually only have open the ones I’m working with at the moment. But I may collect documents for other databases through the day. Using the folder actions or automator would require that I keep open any databases that I want to deposit files into.

The global inbox and the Sorter don’t require that DT or specific databases be open. They’re handy places to drop items, and when the appropriate database is opened it also imports the documents. With the sorter, I can define a bin for any group in any database I like. It’s very handy. However, the Sorter is not scriptable! So I can’t have Hazel automatically add things to sorter groups.

I deal with downloaded (or scanned with OCR) documents using Hazel and some Applescript to get the file automatically renamed and filed into the appropriate DTPO database group. No need to mess around with manual renaming and filing and moving files etc.

Basically, a similar system to MacSparky (detailed in his paperless book) but I use DTPO rather than a nested folder system.

Hazel watches my downloads (or my scanned documents folder), and then renames the file based on rules. The new date match feature in Hazel is a massive timesaver.

I then have Hazel execute a bit of Applescript to move the file into the appropriate database and group. As the file is actually copied, you need to also have Hazel delete the original file.

This is the Applescript I use (I think I found it on these forums a long time ago). You’ll need to update the path to where your database is (I keep mine on a G-Safe Raid 1 drive).

You can change “Inbox” to whatever group you want.

You don’t need to have DTPO running as the Applescript will automatically open it. I don’t bother to close it once Hazel has run.

tell application id "com.devon-technologies.thinkpro2"
    set theDatabase to open database "/Volumes/G-SAFE/DTPO/Database.dtBase2"
    set theGroup to create location "Inbox" in theDatabase
    import theFile to theGroup
end tell

Darren I like this :slight_smile: thanks, being a newbie to Hazel I wonder if you could give a screen shot of your Hazel set up to accomplish this please?

Any chance Darren…please?

The Hazel setup that I document in the last post of this thread must be similar to what Darren has created. The major difference would be that my rule works with indexed folders while Darren’s calls a script to import the document. Just modify the trigger conditions to make it unique for your situation, and replace the move to index folder part with a command to call the above-mentioned script that copies the file, and then add a final command to delete the original file and you should be all set.

Thanks Greg.

Hi, Sorry I missed your post.

This is the Hazel rule which runs on a specific folder.

The applescript is show here. You’ll need to edit it slightly to your own paths and database group.

There’s also this, from another thread.

If a document is already available in PDF format, I prefer to download that, rather than print to pdf.

One reason is that Apple’s PDF generator created pretty big files compared to just about any other PDF tools.

It’s also not very smart. If you are viewing a PDF, and choose “Print -> Save as Pdf…” it creates a new PDF instead of simply saving the existing one. I just did a test using the DevonTHINK Pro Office manual, and the generated PDF was 20% larger than the original.

Still, using your message as a starting point, I solved my own problem which was similar to that of WaldoNJ (who started this thread).

I have a DEVONthink Import folder on my desktop, but the the script I had attached to that folder was Import & Delete. I switched it to Import to selected group, and that solved one problem but created another. Now my files were piling up in my DEVONthink Import folder.

So I modified the script. I named my new script Import to selected group & Delete, and it does exactly what I want.

Since others may find it useful, I’m including the code below. I’m also attaching it to this post here:DEVONthink - Import to Selected Group & (3.46 KB)If you want to use it, download it and save it to:
~/Library/Scripts/Folder Action Scripts

(Normally I wouldn’t zip such a tiny file, but the forum software here won’t let me upload a file with a .scpt extension.)

-- Import to Selected Group & Delete
-- A Folder Actions script intended for use with DEVONthink
-- Created by Steven Klein, August 1, 2014.

-- Based on similar scripts created by Christian Grunenberg.
-- His scripts are copyrighted; I assert no copyright over this script.

on adding folder items to this_folder after receiving added_items
		if (count of added_items) is greater than 0 then
			tell application id "DNtp"
				set theGroup to display group selector
			end tell
			repeat with theItem in added_items
					set thePath to theItem as text
					if thePath does not end with ".download:" and thePath does not end with ".crdownload:" then
						tell application id "DNtp"
							set theRecord to import thePath to theGroup
							if exists theRecord then tell application "Finder" to delete theItem
						end tell
					end if
				end try
			end repeat
		end if
	end try
end adding folder items to

The script is nice. Thanks. For many users it’s simpler to change the Import preference to “Select Group” instead of “Inbox”. Doing so causes the standard “import” folder action to trigger DEVONthink’s prompt for the destination group.

Many thanks for this script @stevenjklein, it’s exactly what I was hoping to find when I logged in.

I am enjoying the thread as well. Hazel is a powerhouse Mac app that I way underutilize. I will see how I can do this as well.

I have a macro that I still have to build to resolve downloading a CSV file that will format properly for use with MoneyDance. I am not sure how people say they are using DTPO for their finances? Curious to hear more on this?

Just to mention It as the OP states newness to the MAC OS, KeyboardMaestro is another powerhouse app. With KM, essentially a system wide macro app that can also run Applescripts, trigger menus and all sorts of things, there is much you can do.

I recently used KM to solve a problem where RichText Notes in DTPO print too small. Using one key press a KM macro tells DTPO to open with text edit, and It does. It was so much easier and far more pleasant that figuring It out using Applescript.

I don’t use DEVONthink to track my finances. I do use it as an archival solution for statements, tax forms, etc. That makes it really easy to go back and research things if I need to.

I think actually tracking expenses and income, categorizing, etc is best done in software that understands money. For me, I do reporting off a homemade database with some R code (because hey, I’m a programmer) but there are a lot of packages out there which can work for you.

Wow. It certainly was easier for you to do this, wasn’t it? :smiley: