Page 1 of 1

How to stop Hazel from re-processing files

PostPosted: Thu Aug 16, 2012 6:36 pm
by Bonanzan
I'm setting up rules to extract PDF invoices that have been received in Apple Mail. As I build this set of rules I would like to extract not only new invoices that come in today but also extract previous invoices that match the rule.

I have been successful in configuring the first two rules (2 different vendors) I've created to work perfectly to accomplish the desired task. The problem comes when I make a change to one of the rules or add a new rule to the group of rules that watch the mail folder and subfolders. After the addition or change Hazel frequently re-runs the rules from the beginning and creates many duplicate files that I don't want. I have the "do not copy if duplicate" setting checked in multiple places in the process but still get the duplicates. I would like to continue adding new rules to this folder's set for additional vendors without generating duplicates for all of the previous matches.

Yesterday I had an issue (unrelated to Hazel) that required me to boot in safe mode, fix the problem, and then restart normally. After the restart, Hazel again started these Mail rules from the beginning and added a full set of duplicates to my filing system.

How can I stop Hazel from re-processing files that it has previously matched successfully?

Re: How to stop Hazel from re-processing files

PostPosted: Fri Aug 17, 2012 12:20 pm
by Mr_Noodle
Normally, if a file matches the same rule over and over, it will only run the actions the first time. If you change a rule, it will re-fire because it is now different. Hazel can't know whether you mean to change it only for future files or are changing it to correct something. Not sure about the safe mode issue but if something happened to your system where the files matched a different rule (or no rule at all) and then matched the original rule again, it would re-fire.

You should try configuring the rules so that they won't match again. The best way is to move the files somewhere else (have a separate folder for processing and done). Other options include coloring the file.

Re: How to stop Hazel from re-processing files

PostPosted: Fri Aug 17, 2012 3:11 pm
by Bonanzan
Thanks, Mr_Noodle for the prompt reply.

I have been changing the rules to do a little "tweaking", which will cause the rule to re-run. (Question: Does creating a new rule which runs on the same folder trigger Hazel to re-run all of the rules for that folder?)

I thought I understood (through trial and error) how to make the process work correctly. I am already using both an extra processing location and some color coding as you suggested. However I am still getting duplicates. The thing I don't get is why Hazel copies a duplicate version of a file even though the "Do not copy if a duplicate" option is checked. I have that option checked on each step of the operation.

In one location the "Do not copy" is checked along with the "replace" button. This is in my processing folder. If I watch the folder as Hazel runs I can see that Hazel is replacing the file with a new copy of the file. These file names are the original ones and Hazel has not yet been asked to rename them. Although the name of the file doesn't change I can watch this taking place because I have the the file being colored yellow when it's placed in that folder and changed to grey once it is matched and a copy of the file is moved to the destination folder. Because it is replacing the file and not renaming the new one I don't end up with duplicates in the processing folder. But, because the file changes, Hazel then runs a separate rule on the processing folder to put a copy of the new file in the destination folder. Why would Hazel be replacing the file in the first place if the "Do not copy if a duplicate" option is checked?

The rule for copying the file from the processing folder to the destination folder also has "Do not copy if a duplicate" option checked, but with the "rename" button selected. In this case Hazel still copies the file over but appends the -1, -2, etc. to the end of the file name. Hazel must think the file is a duplicate if it is automatically renaming the file, yet it seems to be ignoring the "Do not copy if a duplicate" option which is checked.

Writing this all out has made me think of a new question . . . Would Hazel consider a file to NOT be a duplicate if the files were identical with the exception of the highlight color? I was color coding the files as they move around so that I could better follow what Hazel was doing. But if this is the cause of Hazel not knowing that both files are actually duplicates I may have to remove all coloring. I would hate to do that just as an experiment unless you think it is necessary, as the coloring is what makes it easier to identify and remove the duplicates when they are mixed in with everything else. And that's something I have had to do frequently.

I could send you the rules if you think you need to look at them. Or, I will run any test you think I should.

Re: How to stop Hazel from re-processing files

PostPosted: Mon Aug 20, 2012 3:08 pm
by Mr_Noodle
There are two things going on here: whether a file has the same name as one that is already at the destination and whether it is a duplicate. Those are two different things.

A duplicate is an exact copy, which means that it is byte-for-byte identical to the other file. In such cases, you can opt to not do the copy since the exact file exists already at the destination.

For the other options, it's for files with the same name which aren't necessarily duplicates. In such cases, you can specify whether to copy over the one that is there (regardless of whether they are duplicates) or rename it so you don't lose the other file. I suggest taking another look at your rules with this in mind.

Re: How to stop Hazel from re-processing files

PostPosted: Sat Mar 09, 2013 10:52 am
by HirnHorn
I've been trying different approaches to this problem and have come up with my personal favourite solution:

In the rule that processes my files I insert a condition:

[Comment] [does not contain] [whatever]

and then I insert the action:

[Add comment] with pattern: [whatever]

That way every file is processed once and will not be processed again. I personally use "filed" instead of "whatever".

This only works if ALL of the conditions are met for the files or folders.

Re: How to stop Hazel from re-processing files

PostPosted: Tue Jul 04, 2023 5:31 am
by Smithvs1
[quote="Mr_Noodle"]Normally, if a file matches the same rule over and over, it will only run the actions the first time. If you change a rule, it will re-fire because it is now different.

Question on the above. Will this hold true if a computer is disconnected from a server then reconnected? If the programs runs again once reconnected, will it add an additional copy of the files already sorted?

I want to move a bunch of files from one folder on our server to another. But I am afraid if I log off and then re log on when Hazel runs the program again it will make duplicates since it was disconnected from the server. Please advise.

Re: How to stop Hazel from re-processing files

PostPosted: Tue Jul 04, 2023 9:34 am
by Mr_Noodle
It shouldn't but there are several factors in play here that the only way to know for sure is to try it. Set up some test folders and files and see if it behaves as expected. Otherwise, you will need to add extra conditions to prevent this from happening, like checking dates or settings tags on the file.

Re: How to stop Hazel from re-processing files

PostPosted: Tue Jul 04, 2023 10:27 am
by MacOCD
I tend to include colour flags to prevent the chance of reprocessing.

In the Rule conditions
If Color flag is NOT Green...

In the actions
Set Colour flag to Green.

Having a separate processed folder that the file is moved to post processing is a cleaner method though :D