# Is Hazel still real useful for using with Devonthink?

**URL:** <https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972>\
**Category:** DEVONthink\
**Created:** [December 23, 2022, 12:54am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972 "2022-12-23T00:54:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![NorthStar](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/n/f475e1/32.png) [@NorthStar](https://discourse.devontechnologies.com/u/NorthStar)\
**Post date:** [December 23, 2022, 12:54am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/1 "2022-12-23T00:54:10Z")

</div>

Just curious if anybody is still using this combo and if it is useful at the end of 2022 here.

I use CleanMyMac to help delete programs thoroughly. But finding files and organizing them and that kind of thing might be useful to me.

What I think would be really useful is if it could figure out where a lot of the PDFs that I have should go. Which database.

Thanks.

---

<div class="post-metadata">

**Author:** ![Stephen\_C](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/stephen_c/32/8107_2.png) [@Stephen\_C](https://discourse.devontechnologies.com/u/Stephen_C)\
**Post date:** [December 23, 2022, 6:30am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/2 "2022-12-23T06:30:44Z")

</div>

In my experience the combination of Hazel and DEVONthink allows you to develop really [sophisticated workflows](https://discourse.devontechnologies.com/t/exporting-from-day-one-and-importing-into-devonthink-pro-the-procedure-in-detail/72238) for manipulating files. I would not wish to be without either app.

In passing, and expressing a purely personal opinion, CleanMyMac does _not_ fall into that category of app. I’m exceptionally wary of apps that purport to "clean” things. Where appropriate I rely on Hazel, again, to delete unwanted linked files when deleting an app (after rather careful consideration of the list of files that will also be deleted).

Stephen

---

<div class="post-metadata">

**Author:** ![DTLow](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/dtlow/32/18161_2.png) [@DTLow](https://discourse.devontechnologies.com/u/DTLow)\
**Post date:** [December 23, 2022, 6:36am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/3 "2022-12-23T06:36:16Z")

</div>

> [@Stephen\_C](#):
>
> In my experience the combination of Hazel and DEVONthink allows you to develop really [sophisticated workflows](https://discourse.devontechnologies.com/t/exporting-from-day-one-and-importing-into-devonthink-pro-the-procedure-in-detail/72238) for manipulating files. I would not wish to be without either app.

Can you identify some Hazel use cases?  
I use a combination of AppleScript and Devonthink

---

<div class="post-metadata">

**Author:** ![Stephen\_C](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/stephen_c/32/8107_2.png) [@Stephen\_C](https://discourse.devontechnologies.com/u/Stephen_C)\
**Post date:** [December 23, 2022, 6:59am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/4 "2022-12-23T06:59:18Z")

</div>

> [@DTLow](#):
>
> Can you identify some Hazel use cases?

By all means: one is, of course, in the link in my post. Here are a few others:

1. I archive my DEVONthink databases weekly by way of additional backup (and use a script to do so). Hazel ensures that only the last two backups remain in the backup folder on my Mac (i.e., it prunes any backup older than the last two—which is what I want). (I have other apps—like Capture One—that create regular automatic backups and use Hazel in the same way to ensure I keep only the two most recent backups.)

2. I use Hazel to move classical music downloads to a specific folder for processing.

3. Specifically, in the context of DEVONthink, Hazel renames many different downloaded bills and statements and transfers them to the DEVONthink inbox for further automatic processing in DEVONthink.

Stephen

---

<div class="post-metadata">

**Author:** ![rmschne](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/r/8baadc/32.png) [@rmschne](https://discourse.devontechnologies.com/u/rmschne)\
**Post date:** [December 23, 2022, 8:07am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/5 "2022-12-23T08:07:41Z")

</div>

Along with @Stephen_C, I would not want to be without Hazel. Not everything I do with Hazel is related to DEVONthink, but when it is I find it more convenient to use Hazel Rules to interrogate incoming files’ content and take decision on name, etc. No jumping through hoops for me with AppleScript, JavaScript, or Python. I do have some more sophisticated stuff based on Python called from Hazel. I have Hazel so I use it.

Here is a document which describes the setup (written a while back).

Inspired by @Stephen_C (or perhaps reminded!), I also automatically make weekly backup “archive” of all databases into Zip Files. I’ll setup a Hazel rule to delete all but the last two. Been wanting to do that for some time!

[DEVONthink and Hazel Productivity.pdf](https://discourse.devontechnologies.com/uploads/short-url/r83CimZt8A8k3QTEM5OgbNLDkqv.pdf) (1013.7 KB)

---

<div class="post-metadata">

**Author:** ![NorthStar](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/n/f475e1/32.png) [@NorthStar](https://discourse.devontechnologies.com/u/NorthStar)\
**Post date:** [December 23, 2022, 11:57pm UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/6 "2022-12-23T23:57:47Z")

</div>

Thanks everyone for your responses. Hopefully this will be a general response back to everybody.

Based on these responses I will be picking up Hazel today.

I really appreciate the help. What a wonderfully supportive community.

---

<div class="post-metadata">

**Author:** ![rpallred](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/rpallred/32/18214_2.png) [@rpallred](https://discourse.devontechnologies.com/u/rpallred)\
**Post date:** [December 24, 2022, 12:20am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/7 "2022-12-24T00:20:36Z")

</div>

> [@Stephen\_C](#):
>
> - archive my DEVONthink databases weekly by way of additional backup (and use a script to do so). Hazel ensures that only the last two backups remain in the backup folder on my Mac (i.e., it prunes any backup older than the last two—which is what I want). (I have other apps—like Capture One—that create regular automatic backups and use Hazel in the same way to ensure I keep only the two most recent backups.)

I’m trying to do something similar with Hazel (keeping only the last archive of the day)–would love to see your workflow.

> [@Stephen\_C](#):
>
> - I use Hazel to move classical music downloads to a specific folder for processing.

I use Hazel to copy newly (and legally!) downloaded eBooks, photos, and music from my MBP to the appropriate family media server locations after I have cleaned up metadata.

> [@Stephen\_C](#):
>
> - Specifically, in the context of DEVONthink, Hazel renames many different downloaded bills and statements and transfers them to the DEVONthink inbox for further automatic processing in DEVONthink.

I use this feature extensively! Any statement or bill that hits my download folder gets scanned by Hazel, renamed, and added to DT Global Inbox where I can have some Smart Rules do further processing and filing–there are likely ways to do this all in DT, but some of these workflows pre-date my switch from EN to DT and they just work.

I also use Hazel to run [Zowie](https://discourse.devontechnologies.com/t/a-new-tool-for-zotero-users/60025) every time I add a new reference to Zotero to make it easier to work with journal articles in both Zotero and DT.

---

<div class="post-metadata">

**Author:** ![Stephen\_C](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/stephen_c/32/8107_2.png) [@Stephen\_C](https://discourse.devontechnologies.com/u/Stephen_C)\
**Post date:** [December 24, 2022, 6:11am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/8 "2022-12-24T06:11:54Z")

</div>

> [@rpallred](#):
>
> I’m trying to do something similar with Hazel (keeping only the last archive of the day)–would love to see your workflow.

On the assumption you’re referring to the Hazel part you just need a very simple Hazel rule for each of the archived databases, along the following lines (and linked, of course, to your backup/archive folder):

 ![2022-12-24_06-07-31](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/8/a/8a550430cd094abe2bc98e088b44e129275fefbe.jpeg)

If you were also referring to seeing the archive script I can of course post that if you need it.

Stephen

---

<div class="post-metadata">

**Author:** ![rpallred](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/rpallred/32/18214_2.png) [@rpallred](https://discourse.devontechnologies.com/u/rpallred)\
**Post date:** [December 26, 2022, 10:41pm UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/9 "2022-12-26T22:41:38Z")

</div>

> [@Stephen\_C](#):
>
> If you were also referring to seeing the archive script I can of course post that if you need it.

Sure, if you’re inclined…This is giving me some fine ideas…

---

<div class="post-metadata">

**Author:** ![Stephen\_C](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/stephen_c/32/8107_2.png) [@Stephen\_C](https://discourse.devontechnologies.com/u/Stephen_C)\
**Post date:** [December 27, 2022, 6:49am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/10 "2022-12-27T06:49:41Z")

</div>

> [@rpallred](#):
>
> Sure, if you’re inclined…

Note: this is based upon the `Daily backup archive` script included with DEVONthink so much of the credit for the script goes to @cgrunenberg.

```auto
-- First set the path of the folder to which you wish to backup
property pbackup_path : "/Users/[your user name]/Documents/DevonThink/Backups/"

tell application id "DNtp"
	
	-- We are going to set the date format to add to each archived database
	set this_date to do shell script "date +%Y-%m-%d-%H-%M-%S"
	set all_databases to every database
	
	try
		display dialog "Create backups of all open databases?" with title "Backup all open databases" buttons {"Cancel", "Continue"} default button {"Continue"} with icon 1
		
		-- Set a general progress indicator
		show progress indicator "Weekly backup of all open databases…" steps count of all_databases
		
		repeat with this_database in all_databases
			set this_name to name of this_database
			
			-- We use the backup path property here
			set this_archive to pbackup_path & this_name & " " & this_date & ".dtBase2.zip"
			
			with timeout of 3600 seconds
				
				-- Show which database we're processing
				step progress indicator this_name as string
				
				if (verify database this_database) is not 0 then error "Database --" & this_name & " is damaged."
				
				if not (optimize database this_database) then error "Optimisation --of database " & this_name & "failed."
				
				if not (compress database this_database to this_archive) then --error "Backup of database " & this_name & "failed."
				end if
			end timeout
		end repeat
		hide progress indicator
		
		-- Show an alert when it's all done
		display alert "Backups of all open databases complete."
		
	on error error_message number error_number
		hide progress indicator
		if the error_number is not -128 then log message "DEVONthink:" & error_message
	end try
end tell

```

Stephen

---

<div class="post-metadata">

**Author:** ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)\
**Post date:** [December 27, 2022, 8:51am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/11 "2022-12-27T08:51:37Z")

</div>

Just one question: Why do you introduce the variable `all_databases` instead of simply referring to `databases`, which is a property of the `Application` object in this case? I’d probably write  
`repeat with this_database in databases`  
but maybe that’s not possible for some reason?

---

<div class="post-metadata">

**Author:** ![Stephen\_C](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/stephen_c/32/8107_2.png) [@Stephen\_C](https://discourse.devontechnologies.com/u/Stephen_C)\
**Post date:** [December 27, 2022, 9:38am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/12 "2022-12-27T09:38:45Z")

</div>

Pass… 😊 If I recall correctly I took that part of the script from someone else’s script on here. You should know by now that I program blindly and if something works I leave it well alone! 😁

Apologies for inadequacies!

Edit: for anyone interested, this is the [original thread](https://discourse.devontechnologies.com/t/backup-all-open-databases/50932) from which my script was developed.

Stephen

---

<div class="post-metadata">

**Author:** ![awaldraff](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/a/ad7895/32.png) [@awaldraff](https://discourse.devontechnologies.com/u/awaldraff)\
**Post date:** [December 29, 2022, 7:06pm UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/13 "2022-12-29T19:06:00Z")

</div>

personally, I would love for DT to implement the flexibility of Hazel’s rules. I believe DTS rules are more complex to implement and not as flexible/powerful.

For example, I have not been able to find a way to classify files in DT by Month/ day using a short month name for the folder using rules. I am sure it’s doable by using AppleScript. Most of the work I have to do in DT is classifying stuff manually.

---

<div class="post-metadata">

**Author:** ![dgbeecher](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/dgbeecher/32/5352_2.png) [@dgbeecher](https://discourse.devontechnologies.com/u/dgbeecher)\
**Post date:** [December 30, 2022, 12:27am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/14 "2022-12-30T00:27:29Z")

</div>

I have about 60 Hazel rules that automatically identify and re-name all statements that I receive regularly, such as for banks, utilities, etc. It then sorts them directly into the appropriate DEVONthink group, which I specify in the embedded AppleScript when setting up each rule. The Hazel rule generally looks like the following (varying, of course, depending on the formatting of each statement):

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/1/e/1e54dfe9a5fe63d1c7f0e096f80f0dbc3ea9656d.png)

… and the AppleScript looks like this:

```auto
set _theID to "AFB4D3B8-F8B3-4C6C-9925-10622CA3B7F0"

tell application "Finder"
	set _path to (the POSIX path of theFile as string)
	set {_name, _extension} to {name, name extension} of theFile
	set _name to text 1 thru -((count _extension) + 2) of _name
end tell

tell application id "DNtp"
	set theGroup to get record with uuid _theID
	set theImport to import _path name _name to theGroup
end tell

```

This is a modified version of a script I found on these forums long ago, and am sorry to have lost track of who first developed it (possibly the mighty korm?). The main change I recall making was to put `_theID` up at the top, which makes it easier when setting up the rule to paste in the group UUID (which I obtain by selecting `Copy Item Link` and deleting the `x-devonthink-item://` part).

I find this setup very useful, and have not yet found a way to replicate the whole process using DEVONthink alone. The main thing I can’t figure out is how to extract the date from the PDF contents as robustly as Hazel allows. If anyone can tell me how to do so, I would appreciate it 🙂

And if anyone has questions about my setup above, I’d be happy to try to help.

---

<div class="post-metadata">

**Author:** ![rmschne](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/r/8baadc/32.png) [@rmschne](https://discourse.devontechnologies.com/u/rmschne)\
**Post date:** [December 30, 2022, 7:20am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/15 "2022-12-30T07:20:22Z")

</div>

Excellent, and I do pretty much same (although after tagging and name a document and into DEVONthink I don’t much care about setting it into a complex hierarchical Group or folder). Probably got the idea from this forum also! Agree that Hazel quite robust and powerful for handling dates. Nothing wrong with exploiting the the power of the pair–Hazel and DEVONthink. 😉

---

<div class="post-metadata">

**Author:** ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)\
**Post date:** [December 30, 2022, 7:55am UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/16 "2022-12-30T07:55:02Z")

</div>

I do the same with a single smart rule and a JavaScript script in DT.

I described the script here some time ago. Searching for „Hazel maybe“ should tell you more.

---

<div class="post-metadata">

**Author:** ![meta](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/meta/32/5928_2.png) [@meta](https://discourse.devontechnologies.com/u/meta)\
**Post date:** [December 30, 2022, 2:06pm UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/17 "2022-12-30T14:06:29Z")

</div>

Since we’re talking about Hazel and filing stuff… I too have both Hazel and DEVONthink. However, I haven’t used them together — I prefer to file things in DT in a carefully organized fashion.

The thing I do use Hazel for is trashing files. I have a temporary folder for random work in progress, and I have Hazel watch that folder and my Downloads folder. Once a file has been there for 2 weeks, Hazel uses Finder labels to turn it red. After another 2 weeks, Hazel puts it in the trash.

This will probably sound like a crazy way to use software, but honestly it has been life-changing. No more folders full of stuff I can’t remember what it was for and don’t dare delete. If it’s important and needs to be kept I put it in the right place. If not, I forget about it. I just wish I could do the same with paper mail.

---

<div class="post-metadata">

**Author:** ![rmschne](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/r/8baadc/32.png) [@rmschne](https://discourse.devontechnologies.com/u/rmschne)\
**Post date:** [December 30, 2022, 2:10pm UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/18 "2022-12-30T14:10:30Z")

</div>

> [@meta](#):
>
> However, I haven’t used them together — I prefer to file things in DT in a carefully organized fashion

How is using Hazel precluding your use of DEVONthink in your “carefully organised fashion”. Just curious.

---

<div class="post-metadata">

**Author:** ![Lynx](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/lynx/32/25090_2.png) [@Lynx](https://discourse.devontechnologies.com/u/Lynx)\
**Post date:** [December 30, 2022, 2:42pm UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/19 "2022-12-30T14:42:46Z")

</div>

@chrillek

Is the script at

[https://bru6.de/jxa/docs/automating-applications/devonthink/OCR%20and%20move%20to%20group%20for%20DT.js](https://bru6.de/jxa/docs/automating-applications/devonthink/OCR%20and%20move%20to%20group%20for%20DT.js)

the current version? Or is there an updated version?

---

<div class="post-metadata">

**Author:** ![Lynx](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/lynx/32/25090_2.png) [@Lynx](https://discourse.devontechnologies.com/u/Lynx)\
**Post date:** [December 30, 2022, 2:47pm UTC](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972/20 "2022-12-30T14:47:02Z")

</div>

@dgbeecher

Can you explain, what this block does? I’m not very familiar with AppleScript:

```auto
tell application "Finder"
	set _path to (the POSIX path of theFile as string)
	set {_name, _extension} to {name, name extension} of theFile
	set _name to text 1 thru -((count _extension) + 2) of _name
end tell

```

[Next page](https://discourse.devontechnologies.com/t/is-hazel-still-real-useful-for-using-with-devonthink/73972.md?page=2)
