Is Hazel still real useful for using with Devonthink?

Perhaps you should move this conversation to a new thread in “Automation”?

That’s the most recent version. It’s only a proof of concept and has to be adopted to your situation: kind of documents, databases and groups.

is Krom still alive, Haven’t seem him since 2020

1 Like

Can you clarify this, including an example document and what the expected group hierarchy would look like?

Indeed, he is but he seems to be enjoying quieter times nowadays :slight_smile:

3 Likes

Hi bluefrog

I archive my bills using the date of creation of the file. The folder should follow a structure similar to 2022/12-Dec. I have not been able to do it. I can do 2022/12-December by using the following rule

Some other files I would like to file with a similar structure but the date should be modification date. But what I Would really like to do (I do this with hazel) is organize my file automatically based on a combination of tags.

For example a file tagged #reference, 1152-001 | bills should go to the database reference and filed under a structure that goes 1100 - personal/1150 - financials/1152-001 | bills

This is very easy using Hazel, but (to my knowledge) impossible in DT

It’s certainly not impossible, but it would likely require scripting to accomplish it. This is especially true as querying multiple tags doesn’t allow you to differentiate, e.g., by index. This means you couldn’t make a smart rule with built-in actions that would get the third tag on a file and do something based on that.

To tell the truth, I’m not entirely sure, and my interpretation of this block of code is probably as good as yours. At this point, the file has already been renamed by Hazel. This code seems to be talking to the Finder, looking at the file, and sorting out what is the name and what is the extension. In the following part of the code, where it’s talking to DEVONthink, it uses that information about name/extension to help import the file properly. That’s about all I can figure out about it, sorry :wink: … it seems to work, though!

1 Like

What the code seems to be doing: chop off the extension from the name and use the truncated name in DT. Awfully complicated, and I’m not sure that is necessary at all – doesn’t DT use the filename anyway if you don’t provide a name in the import method?

In The Other Language, it becomes a two-liner:

const app=Application("DEVONthink 3"),
app.import(theFile, {to: app.getRecordWithUuid(_theID),
  name: theFile.replace(/^.*\//,"").replace(/\..*/,"")})

assuming the name can only contain one dot. Otherwise, modify the last replace accordingly.

1 Like

Thanks for taking a look – seems you are right! I deleted all the bits that fiddle with the name and extension, and the script continues to work! – possibly even a millisecond faster, so definitely worth it.

In case anyone is seeking to set these rules up themselves, the newer and shorter code is:

set _theID to "SAMPLE-UUID-81B58CD9-040E-4B80-84D3-12BBA77F65C8"

tell application "Finder"
	set _path to (the POSIX path of theFile as string)
end tell

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

All this interesting talk about Hazel prompted me to try it out. I run into a problem, and I hope someone here can help.

I have a folder, let’s call it A, for the sake of simplicity. Inside this folder are subfolders and in each subfolder there is a PDF document which has the same name as the folder in which it resides.

11

I want Hazel to move the PDFs out of the subfolders and place them into the folder with today’s date, or alternatively, into the folder A. I’m able to move the folders 1,2,3,4 with the PDFs inside, but no matter what I do, I can’t find a way to move just the PDFs. Is it possible?

This is what I have tried:

Interesting question. Perhaps someone here can help you. But you may benefit more by asking over on the Hazel forums:

https://www.noodlesoft.com/forums/index.php

2 Likes

@dgbeecher

I first thought it were just a newbie question, therefore I posted it here. But perhaps Hazel can only monitor root folders, not subfolders. That would be a great limitation, in my opinion.

If you look at the inbuilt Hazel help under Advanced Topics there is a section on Processing Subfolders.

Stephen

4 Likes
  • Why would you want them in a dated folder OR the A folder?
  • And based on what criteria would these be filed in a dated folder?

@Stephen_C,

I think this resolved my problem. Thank you.

The solution is somewhat unexpected. The rule “Go into subfolders” needs to be added—independently—at the end of the rules. For those who might be wondering how this is done, here is the solution:

Hello BLUEFROG,

Thanks for responding.

Because I download daily a zip file containing a large number of news related PDFs. Unfortunately, each PDF comes in a folder which has the same name as the name of the PDF itself. That is redundant. Until now I have always dragged the PDFs manually out of their original folders and then deleted the redundant folders.

Additionally, I need to drag those files which are currently not useful to me (about two dozens every day) into a separate folder. I want to keep those files in case I might need them later.

Sorry, I should have explained that this is a daily routine. At the end of the year 2023 I’ll be having 365 folders, one folder for each day of the year; that explains why I use dated folders.

Since I have now found out how to move files with Hazel out of subfolders I’m confident I’ll be able to delegate the whole drudgery to Hazel in future. :–)

Happy New Year to everyone!

Do you manually create the dated folders in the FInder?

@ BLUEFROG
Yes, that’s what I have done till now, but from now on I’ll let Hazel do it.

How does hazel put it in DevonThink inbox?

I did not know it could call the app.

1 Like