Detecting file changes: really that simple?

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

Moderator: Mr_Noodle

Detecting file changes: really that simple? Tue Nov 04, 2014 6:58 pm • by jfontana
I'm sorry if this sounds like a stupid question. I just started using Hazel an hour ago. I've read the help documentation and I am not able to get Hazel to do what would appear to be one of the simplest things.

I just want Hazel to make a copy of a file to a different folder in Dropbox every time the file changes. I also want it to create a copy of the file in its initial state when I open it to a different folder and keep that copy unchanged until next time I use the app again.

I've been trying to do this in different ways. With rules that copy the file if:
Date last modified is after Date last opened
Date last opened is after Date last matched
and with some other combinations I don't remember.

None of that seems to work. I can see the file in the original folder is modified because the 'dade modified' field changes in Finder but the copied files on the backup folders are not always changed. Some times they are, some times they aren't.

I'm obviously not understanding something that must be very basic. Can anybody lend me a hand? Thanks in advance.

JM
jfontana
 
Posts: 2
Joined: Tue Nov 04, 2014 6:45 pm

Are you trying to copy a file or a folder? Also, what do you mean by "open it to a different folder"?

I suggest going through the troubleshooting guide stickied at the top of this forum.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Hi and thanks to the prompt reply. I just read the troubleshooting guide and while it is very helpful in many respects, it also raises new questions. For instance, I'm not sure about the implications that the fact that "Hazel only applies the first rule that matches" would have on what I'm trying to do. Perhaps it would be better if I'm a bit more specific and clear:

I'm using an app called iDataBase. The information I keep in iDataBase is very important and I want to keep a backup copy in my Dropbox folder (iDataBase allows you to save copies only within the Library folder). This looks rather simple but here's the problem.

iDataBase saves automatically every time you introduce a modification. This is convenient but it seems to be a problem for Hazel (unless I'm doing sth wrong). I don't know how long Hazel takes to monitor a folder but what I'm noticing is that it doesn't really create a new backup copy every time the file changes. To see better whether it is working, I have it set up so that if the file exists, it will rename it and create a new copy. It is very clear that it doesn't create a new copy every time the file changes.

To achieve that I have a first rule (All > Date last modified is after Date Last Opened) that creates 2 copies of the modified file to two different folders. As I say, this doesn't seem to be working. Some times I see a new file being copied but some other times I introduce many changes that are not registered since no new files are copied.

Then comes the second problem and this is where the question about "Hazel only applies the first rule that matches" arises. The other problem that iDataBase has is that many times you cannot recover from changes you have introduced. You might delete a field by mistake and Cmd-Z will not be able to take you to the previous state.

What I wanted Hazel to do was to create a copy of the file when I open it for the first time and keep it on a folder for the length of the session (later on, it should be deleted when I exit the program). This way if I delete something by mistake, I can always open the unmodified version and recover it. For that I created a second rule for the same folder: All > Date last opened is after Date Last Matched.

Here is where I think I might not be doing this right because if this rule is placed after the previous one perhaps by the time Hazel checks there has been some change and then the value of 'Date Last Matched' is no longer lower (before) the value of 'Date Last Opened'.

In essence, what I wanted Hazel to do is rather simple. I want it to keep two different kinds of backups: one which is constantly updated with all the changes that are introduced during an iDataBase session and the other one where only the initial state in the session previous to any changes is preserved.

Am I approaching this totally in the wrong way in terms of the form of the rules (not using 'last modified', 'last open' or 'last matched' appropriately) or in terms of rule ordering?
jfontana
 
Posts: 2
Joined: Tue Nov 04, 2014 6:45 pm

Have you used the preview? Check the date last opened and the date last matched. I suspect date last opened, in particular, is not what you expect.

If you want to track a file every time it is modified, then you really want to use "Date last modified is after date last matched". Date opened can be flakey though so I suggest you actually track that value as it may not work how you want.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thank you so much for this. I was having the same question and same issue. By changing the comparison to "Date Last Matched" that made it work like a champ!
bolive
 
Posts: 1
Joined: Fri Dec 31, 2021 8:10 pm


Return to Support

cron