Difficulty dealing with subfolder depth situation

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

Moderator: Mr_Noodle

In Short, I need Hazel to keep a 1:1 sync via copy of two folders (Folder A and Folder B), read inside all subfolders of A to check for new files, and ignore all files with the keyword "syncthing" in the name. This needs to utilize "if date added is after date last matched" so that I can delete files in B and have them not be re-copied.

My situation is that I have folder 'A' which uses a program called 'syncthing' to sync this folder to a folder on my server. Syncthing creates temporary files, and when the file is finished downloading, it creates a new file with the correct name. I want all of these synced files to be automatically copied to a second folder, folder 'B', and I also want to be able to delete files from folder 'B', without them being re-synced from 'A'. Here's what I have:

folder A
-if [date added] [is after] [date last matched] - so that it only processes the file once
-if [keywords] [do not contain] ["syncthing"] - to avoid adding these temporary files titled '.syncthing01-blahblah.tmp'
-then [copy file] to folder [b]

This works perfectly for files/folders. A problem is that my sync program is going to be adding folders to 'A' that could have any amount of subfolders, and in each of them the process will be creating temp .syncthing files, and then creating the correct files, and deleting the temp files. So at one point, a folder inside of A could look like:

d1
├── d2
│   ├── file3
│   └── syncthing4.tmp
├── file1
└── syncthing2.tmp

and then when the server sync is done, it would look like

d1
├── d2
│ ├── file3
│ └── file4
├── file1
└── file2

Now with the rule I have above, if I added a file to say /path/A/d1/ it would not be copied over to 'B', and hazel will obviously act before the sync is complete. So the next step seems like utilizing the 'go into subfolders' action. Adding this does successfully allow Hazel to read and run actions within /path/A/d1/, however it's now sending the files inside /path/A/d1, to 'B'. I'd like them to stay inside /path/A/d1/.

The best solution here would be if my sync program could download files to a separate temporary folder, and then when the download is complete, move it to 'A'. Then they would copy over just fine. Alas, it can't.

I need hazel to maintain folder structure here, and keep a 1:1 sync of 'Folder A' and 'Folder B' while ignoring all '.syncthing' files (no matter how deep), look into subfolders for new files, and only checking each individual file once so it doesn't re-sync files when deleted in 'B'.

Any advice is appreciated, this one's really throwing me off. Thanks!
jonxfm
 
Posts: 7
Joined: Fri May 04, 2018 5:51 pm

Alright well, shortly after I posted this I think I've figured it out, but unless staff wants to delete it I'll keep it up since this took me forever to figure out.

Folder A
1.) if [name] [contains] [syncthing] - [ignore]
2.) if [date added] [is after] [date last matched] - [copy] to [B]
---options---
a.) if file exists - do not copy the file
b.) ***copy folder structure [from monitored folder]***
3.) if [kind] is [folder] - [run rules on folder contents]

then on B I put another ignore syncthing files, in my tests with touch files this didn't work when dragging folders containing .syncthing files, but in practice it doesn't seem to be a problem.

If somebody has a better way, definitely let me know.
jonxfm
 
Posts: 7
Joined: Fri May 04, 2018 5:51 pm


Return to Support