Hazel Rule & Code to import document directly into DT

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Hi Guys,

I've tried to tackle this issue on the DevonThink forum but it's been suggested I check over here for any ideas.

Essentially I'm trying to get Hazel to run a rule which will then trigger a script to import documents directly into a predetermined group in DevonThink except I'm getting errors in hazel when trying to run the script.

Here is a link to my post with all the details on the DevonThink forum: https://discourse.devontechnologies.com/t/hazel-rule-script-for-importing-indexing-to-a-specific-group/15941/24?u=sebsez

Any help would be appreciated!

Thanks

Seb
sebsez
 
Posts: 5
Joined: Fri Jul 05, 2019 7:11 pm

Well, there are some issues with Finder. Not sure what it's doing at the time.

The other error is maybe related to this line?
Code: Select all
set {_name, _extension} to {name, name extension} of theFile

Maybe you want to use _path instead of theFile there.

If you still can't figure it out, check the logs. Usually there are more detailed errors there.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thanks for the suggestions.

On changing
Code: Select all
theFile
with
Code: Select all
_path
I tried and received the following error in Hazel:

less than a minute ago : Can’t get name of "/File Path/File Name.pdf"

I also had a look at the logs and could not find anything. The rules are all matching, but nothing in the logs about the script executing or there being errors in executing the script.

Code: Select all
2019-07-11 06:37:51.025 hazelworker[40529] Processing folder General (forced)
2019-07-11 06:37:53.041 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:53.949 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:54.348 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:54.652 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:54.892 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:55.125 hazelworker[40529] File .DS_Store is busy. Skipping for now.
2019-07-11 06:37:55.125 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:55.341 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:55.731 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:55.948 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:56.068 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:56.234 hazelworker[40532] Running worker (v4.3.5) for folder with identifier: 16777220-2994127.
2019-07-11 06:37:56.237 hazelworker[40532] ###main load address: 0x106f1f000
2019-07-11 06:37:56.237 hazelworker[40532] ###Noodle load address: 0x10704a000
2019-07-11 06:37:56.237 hazelworker[40532] ###CK load address: 0x107009000
2019-07-11 06:37:56.257 hazelworker[40532] Processing folder Document Inbox
2019-07-11 06:37:56.290 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:56.601 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:56.986 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:57.141 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:57.487 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:57.715 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:57.837 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:58.141 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:58.261 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:58.372 hazelworker[40532] Done processing folder Document Inbox
2019-07-11 06:37:58.923 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:59.150 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:59.193 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:59.405 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:59.705 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:59.745 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:37:59.960 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:38:00.181 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:38:00.334 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:38:00.567 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:38:00.681 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:38:00.749 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:38:00.872 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:38:01.100 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:38:01.227 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:38:01.374 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:38:01.516 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:38:01.577 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:38:02.016 hazelworker[40529] XXX File Name: Rule Import into DevonThink (General) matched.
2019-07-11 06:38:04.152 hazelworker[40529] File .DS_Store is busy. Skipping for now.
2019-07-11 06:38:06.173 hazelworker[40529] File .DS_Store is busy. Skipping for now.
2019-07-11 06:38:06.177 hazelworker[40529] Done processing folder General


The issue is certainly related to running the Apple Script, the guys at DevonThink swear that it works.

PS: I've also tried stopping Hazel, restarting finder and running the rules again... same result.
sebsez
 
Posts: 5
Joined: Fri Jul 05, 2019 7:11 pm

After changing
Code: Select all
_path

back to
Code: Select all
theFile


I keep getting the following error

less than a minute ago : Can’t get name of "/File Path/File Name.pdf"

And no longer getting the original errors posted on the DevonThink forum.
sebsez
 
Posts: 5
Joined: Fri Jul 05, 2019 7:11 pm

Is there a reason why you do not do this in the automator app?
For me that works flawlessly since half a year and even with DT3.

It is pretty straight forward:
Image

you can then add this automator script to hazel.
"Behind all the inhuman aspects of automation (...) its real possibilities appear: the genesis of a technological world in which man can finally withdraw from (...) the apparatus of his labor – in order to experiment freely with it." /Marcuse
Robert
 
Posts: 52
Joined: Sun Dec 16, 2018 8:05 am

Thanks for the Automator example. You should probably get rid of that first action in that workflow since Hazel will pass in the file that needs to be processed.

As for the script, try using "display dialog" to display the values of things at various points in the script. Something like:
Code: Select all
tell application "System Events"
   display dialog <<<whatever it is you need to display>>>
end tell
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support