Duplicate Automator/Hazel import

As I try to dive full bore into DEVONthink, I’m running into an issue with one of the DEVONthink Automator actions creating duplicate entires on import. I’m not sure if it is a Hazel issue, an Automator issue, or a DEVONthink issue. I thought I’d see if anyone else had run into this issue.

Hazel monitors a folder on my Mac called “Action” and scans the files in that folder for certain content. Below is one example (if a file matches parameters showing it is my cable bill, it renames the file, and then launches an Automator action that sends it into DEVONthink)


And here is the Automator workflow:


Everything works fine, with the item moved into DEVONthink and placed in the proper group. An identical copy of the item, however, is also moved into DEVONthink and placed in a newly created subfolder in the proper group. This newly created subfolder is called “Action,” leading me to believe that the Automator action is somehow preserving my directory structure (including my “Action” folder in the Finder) on import.

Thank you in advance for any insights, as I get my brain around this amazingly powerful app.


I would lean toward this being a Hazel issue rather than the Automator workflow. But it’s easy to troubleshoot by disconnecting the integration between Hazel and Automator.

Eliminate the Hazel dependency on the Automator side, for example, by making a service in Automator using exactly the same actions. Select a document in Finder, and run the service. If you get two imports, then you know it’s a DEVONthink problem.

Then, eliminate the dependency on the DEVONthink on the Hazel side, by modifying the Hazel rule to change the Automator action to one that merely pops a message (“display a notification” action). (This avoids the DEVONthink dependency). If you get two messages, then you know it’s a Hazel problem. If it’s Hazel, contact Paul Kim at Noodlesoft – he is super helpful.

Thank you for the reply. If I did this right, I think you are correct. To test, just now I selected the file in the Finder (from somewhere other than my Action folder, to make sure Hazel wouldn’t be triggered), and then clicked the button to run the Automator workflow. It cleanly moved the file over. I will try to replicate this process over the weekend to make sure it is isolated to Hazel, and head over to those forums. Thanks for the suggestion.

Evan, when you’ve finished your troubleshooting please post an update here – whether or not it is a DEVONthink issue. Many DEVONthink users like to work with Hazel and your tips will be helpful for the community here.

I second that, FWIW! Good luck!

I certainly will, Korm. I just made a post in the Hazel forums, so we’ll see if that gets me anywhere.

I thought I had pinned this down to only happening when I had the Hazel preference pane was open, but then it started happening even with it closed. Oddly, I got even stranger behavior this morning. I moved a file from my Desktop into my Hazel-monitored “Action” folder. That file was moved into the proper place in DEVONthink, but was then moved a second time, along with the entire contents of my Desktop. My Desktop isn’t even monitored by Hazel, aside from a cleanup rule that I’ve been using for a couple of years. It’s almost like Hazel traced the file back to its original location, and grabbed the entire Desktop folder.

I wonder if I’m going to find that this is something unique that I’m doing on my end, that I’m completely unaware of.

For the record, here:

Unintentionally creating duplicates in Devonthink

The Noodlesoft (Hazel) site appears to be down at the moment, so I can’t see the specifics, but another user did post a reply this morning. I forget the specifics, but it seemed to suggest (or at least got me to think) that the problem could be caused by selecting the file in the Finder when the Hazel rule and the Automator action are run.

I have to test it some more, but in a quick test, this might be the problem. It seems that when I have selected a file in the Finder (clicking on it once), the Automator action runs not just on the contents in the Hazel-monitored folder, but also on the file or folder I’ve selected. This is problematic, since I often drag files into the Hazel-monitored folder (resulting in a file that is selected).

Since the Hazel site is down, I can’t see if there were any suggestions there on how to monitor the Automator workflow so that it looks only at what is in the Hazel-monitored folder, and not at what I’ve selected.

EDIT: the Hazel forums are back up. Here is the thread:


I’m going to try to find time today to test the suggestion out.

A quick update: I haven’t used/tested this long enough to be 100% sure, but a couple of observations:

  1. There doesn’t appear to be a difference between saving as an Automator Workflow or as an Automator App. At times, I get duplicates as mentioned above for either.

  2. One factor that I think is consistent: after moving a file into my “Action” folder (the one that Hazel monitors), if I quickly click a blank area on the desktop or elsewhere, then I don’t get the duplicate. I’m assuming this is because of the “get selected item” first step in Automator.

I don’t know enough about Automator to come up with an alternative first step, unfortunately.

I doubt that it is clicking the desktop that causes the Finder action in Automator to do anything different. The action is triggered by Hazel, not the mouse.

What happens when you drag a file onto the Action folder icon without first opening the folder?

Is it possible that you have a Folder Action attached to the folder Hazel is watching - IOW, two sets of rules on the same folder?

I don’t have any Folder Actions on that folder (well, I have an old OCR one, but it is deactivated - the box to enable Folder Actions on that folder is not selected).

I have no clue on this stuff, but was just going on what was said by others in my post in the Noodelsoft forums:


User Skeo stated, “My immediate thought here would be the first item in your workflow. Which is get selected items. That function “gets” whatever is currently selected in the finder. So when hazel runs, it is actioning the workflow, which is then “getting” whatever you currently have highlighted in the finder.” (That’s what led me to belief that just clicking somewhere, so that nothing is “currently selected,” was a bit of a workaround to the issue).

The admin then replied, “Yes, make sure any Automator workflow you use with Hazel takes files as input as Hazel will pass it in.” I’m not sure if he was replying to the first quote, or to a different part of the reply, though.

Folder Actions can be flakey. I suggest creating a fresh new folder (completely different name), deleting your old Hazel rules and the old folder and move the rules to the new folder. This just eliminates one more possibility.

For what it is worth, I didn’t have any Folder Actions on that folder until after this duplication problem manifested itself. (I had been playing around on Sunday with creating a folder that automatically OCR’d PDF’s placed into it, and that was the first Folder Action on that folder). The problem started several days before that. But I will try to clean that up when I get a chance.

Sorry for all the suggestions. :frowning: I’ll make just one more then be silent. Finally I was able to duplicate the problem. I then substituted “Get Specified Finder Items” for “Get Selected Finder Items”. There is a difference between the two. “Specified” is more appropriate for application-to-application parameter passing; “Selected” is (as you found and I didn’t pay attention) works best for user interaction with the workflow. Making that change to the workflow eliminated the duplication over here.

Thank you, thank you, thank you! I will try it this weekend, but that’s exactly the sort of change I was looking for. And thanks for the contributions elsewhere, too. I’ve been getting up to speed with DTPO by browsing around here, and see many of your suggestions that are very helpful.

Just reporting back that I’ve used Korm’s fix on several files over the past couple of days, and all appears to be working fine. I did have one “failed” error in Hazel, but that was isolated so I suspect it was unrelated to this issue.

Thanks, Korm!

This rule in Hazel can help avoid excessive matching and/or false matches:

I would just like to confirm that I was having the same problem, which, after reading this thread, was solved by using the ‘get specified folder items’ workflow. Thanks a lot! :slight_smile:

However, I was also facing another problem. Hazel would import the file in the root of the database, instead of the selected group. Now, I think this happens when that very selected group is simultaneously open in DEVONthink. Am I correct in this? :confused:

I actually gave up on trying to get stuff filed into the correct group via Hazel and Automator. It seemed like it would work, but then “forget” the next time and throw an error (it’s been a while, but I remember it would just throw it into the man inbox and throw an error that it failed). Maybe it’s because my databases are in encrypted sparse images that I mount only when needed.

I now just have Hazel tag everything (Mavericks), rename it, and throw it into DTPO’s Finder inbox. I then use “See Also and Classify,” which is fast and accurate.