Page 1 of 1
Rule for synchronizing folders containing sub-folders

Posted:
Mon Apr 30, 2012 3:28 am
by andreasj
Hello
How can I synchronize/copy a folder with sub-folders containing JPEG-files to an external HD preserving the same folder structure. So, it is just a simple backup process with one way synchronizing. Thanks for your answers
Andreas
Re: Rule for synchronizing folders containing sub-folders

Posted:
Mon Apr 30, 2012 10:06 am
by Mr_Noodle
First off, please do not post questions to the tips forum. There's a sticky article up top telling you not to do this.
As for your question, have Hazel monitor the folder containing the folder you want to sync. Then make a rule as follows:
- Code: Select all
If all of the following are met for current file
Kind is folder
Date modified is after date last matched
If all of the following are met for any sub-file
Date modified is after date last matched
Then
Sync
You may want to add additional conditions to match the specific folder in question. This will sync for every single change. You may also want to consider, instead, syncing on a schedule.
Re: Rule for synchronizing folders containing sub-folders

Posted:
Wed Jun 06, 2012 7:57 pm
by Mondozer
I tried this rule. It worked with test folders but not with my Documents folder which I'm trying to mirror to iDisk. I make changes to documents within the folder on my Mac but Hazel doesn't catch them.
Any suggestions?
Documents Folder on Mac
all conditions met for this file or folder being matched
Kind is Folder
Date last modified is after date last matched
If all conditions met for any of its subfiles of subfolders
Date last modified is after date last matched
Do following
Sync
Send Growl notif.
Re: Rule for synchronizing folders containing sub-folders

Posted:
Thu Jun 07, 2012 5:44 pm
by Mr_Noodle
Actually, just caught an error in the rule I posted. To make sure you catch everything you should do:
- Code: Select all
If all of the following are met for file being matched
Kind is folder
If any of the following are met for file being matched
Date modified is after date last matched
If all of the following are met for any sub-file
Date modified is after date last matched
Then
Sync
Sorry about that.
Re: Rule for synchronizing folders containing sub-folders

Posted:
Fri Jun 08, 2012 12:19 pm
by Mondozer
Mr. Noodle:
Thank you so much. The revised rule works as advertised.
Getting subfolders right is such a challenge for non programmers. I hope you will post this rule to the subfolders sticky where others can easily find it.
Kind regards,
M.
Re: Rule for synchronizing folders containing sub-folders

Posted:
Wed Jun 20, 2012 9:59 am
by toadle
Guys, sorry for a perhaps dumb question, but: How do I create an additional "if"-statement inside another "it"-statement in Hazel?
Re: Rule for synchronizing folders containing sub-folders

Posted:
Wed Jun 20, 2012 1:15 pm
by Mondozer
In the rule folder <option-click> the plus sign at the end of the first rule.
Re: Rule for synchronizing folders containing sub-folders

Posted:
Wed Jun 20, 2012 1:28 pm
by toadle
Thx - a real pro-feature

!
Re: Rule for synchronizing folders containing sub-folders

Posted:
Fri Sep 14, 2012 4:13 pm
by wlai
One question on the updated copy of the rules. As written the rule will skip over the top level files. This is because of the first "Kind is Folder" Is there a way to fix that?
If all of the following are met for current file
Kind is folder
Date modified is after date last matched
If all of the following are met for any sub-file
Date modified is after date last matched
Then
Sync
Re: Rule for synchronizing folders containing sub-folders

Posted:
Fri Sep 14, 2012 4:32 pm
by Mr_Noodle
Get rid of the "Kind is folder" condition.
Re: Rule for synchronizing folders containing sub-folders

Posted:
Thu Aug 22, 2013 2:28 pm
by PackDude
I stumbled across this while attempting to find an alternative to RAID 1. I have two external drives for storing media for my home media server. I am looking for an alternative to RAID, since it crashed my box when I tried using it. All my files will be in sub-folders for organization purposes, usually 2-3 folders deep, depending on the file. Will Hazel be able to handle syncing that deep with the script you provided?
Also, noticed that it appears some of the options have changed since the script above was provided, for example, the second, indented If statement refers to "file being matched", but that's not an option in the current version. It appears to have been changed to "the current file or folder". Similarly, the second nested If statement refers to "any sub file", but the current option is "any of its subfiles or subfolders". Will the script still work as expected with these differences?
Re: Rule for synchronizing folders containing sub-folders

Posted:
Fri Aug 23, 2013 12:28 pm
by Mr_Noodle
I used shorter names in my description. Don't be worried about everything matching literally, instead looking at the actual meaning of it.
And yes, the script itself has no notion of any bounds as far as how deep it will go. Again, though, I suggest analyzing the rule so that you have a better understanding of it and testing it before deploying it.