"Merge to" to copy a folder structure and files.

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

You have a folder structure, on you Mac's hard drive (your monitoted folder). You want to make a backup copy on an external or cloud drive (your desitnation folder) from which no file of folder will ever be deleted, even if it is accidentally deleted on the original source folder structure.

Writing individual rules for each subfolder may be impractical especially if you don't yet know their names,or if there are many of them.

You need to use a "Merge to" function. But Hazel has no "Merge to" function.

At first site it may seem easy to use Synch or Copy, but Synch and Copy will both effectively copy sub-folders "as is". This means that if you accidentally delete a large number of files or folders from your source (monitored folder), they will be effectively gone from any sub-folder on your destination. "Copy" does not avoid this, because it effectively copies over sub-folders with their changed contents. Saying "Do not copy if file exists" would mean that sub-folders will not be updated after they first were created at the destination.

You effectively need two rules for you monitored folder. The first one is shown below. it ensures that all future rules will run on the sub-folders of your monitored folder.

Image

To get it right you need to do the following in the SECOND rule:
1) Ensure that your rule only acts on documents, not folders.
2) Make rules run on folder contents
3) If the file already exists do not copy the file
4) Copy the folder structure from the monitored folder

The last instruction has the effect of building an identical folder structure at the destination external disk if the relevant folder or sub folder does not exist and contains a file. Empty folders will not be copied from source to destination, but if they already exist on the destination, they won't be deleted.

For example, if you change the name of a sub-folder in your monitored folder from say "2022" to "2023" your desitination forlder will have both folders ("2022" is not deleted when it is renamed on the monitored structure.).

Here's how it should look in practice (see photos):

Image
Image

By using these two rules in the order shown, you have effectively created the equivalent of a "Merge to" instruction.

The last action "Display Notification" is not necessary but it's nice to have so that you know when the action is completed.
Trickyt57
 
Posts: 56
Joined: Tue Sep 18, 2018 12:17 am

Return to Tips & Tricks - DO NOT POST QUESTIONS

cron