yet another folder scanning question... :(

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

Moderator: Mr_Noodle

yet another folder scanning question... :( Mon Sep 09, 2013 6:55 am • by glawrie
Hi. I realise there are dozens of similar questions in this forum - apologies for adding yet one more.

I have been through quite a few and have failed to work out what I need to do to get Hazel to work. Partly this is due to confusion on my part about how Hazel works, and partly that what I am trying to do possibly is not possible.

I have an iTunes folder stack on one machine, a network, and a second machine that has a backup of the iTunes folder stack on a disk. Here is what I am trying to do on the second machine:

  • Scan the iTunes stack on first machine and spot new folders / music files being added
  • When a new folder / file is added copy it to the "add to iTunes" folder on second machine

Based on what I think Hazel can do I think this should be possible. But I am getting very confused by the mechanism used to get Hazel to scan nested folders:

  • I am not sure what folder to point Hazel at - some suggestions say it should be the parent folder of the folder I want to scan (which would be .../iTunes Media), others that it should be the folder itself (which would be .../iTunes Media/Music).
  • I have seen some suggestions that say I should have several rules for the folder with the first one being "Go into subfolders", others that suggest I should use nested conditions within a rule (such as in the 'Sync folder "blah" ' example

Finally I've got some questions about specific bits of Hazel functions that are used in the kinds of rules I think I need.

  • I am not clear on how I set the "Date Last Matched" token to not copy everything in the stack the first time I use the rule (which would trigger a hugely long and unhelpful file transaction)
  • I am intending that copying the new file(s) to the "Add to iTunes" Folder on second machine would update its copy of the iTunes stack, but would "import to iTunes" hazel instruction be a better thing to use?
  • I am unclear on the function of the hazel actions "sync" "sort into subfolders" etc. Is there a list somewhere of what these actions do?
  • I am unclear what some of the file tokens actually mean (e.g. what is covered by "music"). Is there a list somewhere of what these file tokens actually mean?

Thanks a lot in advance for help.
glawrie
 
Posts: 6
Joined: Mon Sep 09, 2013 6:07 am

If you just want to mirror one folder to another, see this thread (which is right above this one at this time): viewtopic.php?f=4&t=1593
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:If you just want to mirror one folder to another, see this thread (which is right above this one at this time): viewtopic.php?f=4&t=1593


Thanks a lot for the reply. I am hopeful based on this that my aims are at least plausible, but not sadly any closer to knowing how to achieve them.

The thread you point to is one of the previous questions I had found and read - and indeed was the source of the "Sync Folder blah" ruleset mentioned in my post. Several things confuse me about the thread - from the image given at the head of the thread that shows clearly an option to start a rule with "if any of the following conditions are met for all of its sub-files and folders" which I cannot generate in my copy of Hazel, through to the confusion mentioned in my post about whether it is better to have the 'sub-folder' rules as part of a single hazel ruleset (using "option-click" to open up sub-folder rules) or have multiple rules starting with one to set up applying rules to sub-folders (which is recommended in another post).

Also, it is not clear what folder this rule type should be applied to - the folder with files / sub-folders or the parent of this folder.

So I remain confused...
glawrie
 
Posts: 6
Joined: Mon Sep 09, 2013 6:07 am

The target pop-up for sub-files is a totally different beast than using the "Run rules on folder contents". The former is when you want to match a folder based on its contents. The latter is when you want to match the contents directly. Search the forums as there are probably longer explanations of this with examples.

If you download the sync rule from that thread, that should allow you to do a straight sync of one folder to another when anything in that folder changes.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: yet another folder scanning question... :( Thu Sep 12, 2013 11:03 am • by glawrie
Thanks for reply.

I'm not tuned in enough to the lingo used for Hazel I think - I really don't know what you are referring to by "target pop-up" - is that "option-click" to get the go into folders version of a new rule?

I've got something hooked up that appears to work. But in light of your comments I am really not sure if what I have ended up with is the appropriate way of doing what I want. Grateful if you could cast eye over and confirm it is what I should be doing or suggest alternative as appropriate.

I've set Hazel to run on the second machine and monitor the folder ../iTunes Media/Music on the first machine. I've then created two rules:
  • The first is the 'Go into folders' rule from elsewhere in this forum
  • The second has two conditions within an "if all of the following are met" thing - the first is "if Kind is Music" and the second is "if Date Added is after Date Last Matched"
When the conditions are met, the action set is "copy to 'automatically add to iTunes' folder" on the second machine.

In order to get this to work, I needed also to create a third rule - which has the same conditions as the "add to iTunes" rule, but instead has an action of setting the label colour to "x". This is to allow Hazel to "match" all the files in the stack without actually doing something - so that when I turned on the 'add to iTunes' rule, it didn't then add all the stuff in the stack to iTunes on first pass through (it just adds 'new' stuff).

Two other observations. First, the log file seems to be an essential tool to work out what Hazel is doing - there appears to be no other way to work out what Hazel is doing. Second, there appears to be no easy way to control what Hazel is doing - because the rule I'm working on is running over a wifi connection on a large stack of files, once it starts a scan it can take a few minutes to complete. Testing rules is quite difficult as a result - an easier way to start / stop what is going on would be good.
glawrie
 
Posts: 6
Joined: Mon Sep 09, 2013 6:07 am

For debugging rules, I suggest using the preview function heavily.

Your rules will work with the following caveats:
1. You should also use the option to copy the folder structure across. Without that, all the files will end up in one big folder at the destination.
2. If a file is deleted at the source, this won't delete it at the destination.

Using the sync rule handles both of the above but if #2 isn't a big deal, then what you have should work.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thanks for the pointers.

  • I copied the file stack over manually before kicking off the Hazel rule - it is many GB and so would have taken forever over wifi. So the rule is to catch changes in the source stack, not replicate it, and by implication the file / folder structure is in place. Also, because the rule simply moves the new files to "Add to iTunes" and iTunes then copies the files to the 'right place' in the stack based on the ID3 tags of the file, the destination stack is actually 'self-organising' so the "all files in a heap in one place" risk is not there (in this special case).
  • I have tried to work out how to do the reverse sync, but so far not found a way that doesn't end up in a death-loop: the matter is complicated by the need for whatever is in the stack to replicate in iTunes meta-data. There doesn't appear to be a way to 'delist' tracks from iTunes automagically - and so I suspect that if a track was deleted from either stack there is no way to reflect this in iTunes (other than getting an error when you try to access the now missing file). Not ideal, but what is happening (ensuring new stuff is replicated in iTunes on second machine) is working, so a bit more than half-way to goal I think.
  • For same reason there is no easy way to reflect tracks added to second machine on first machine - you could possibly simply scan for changes in same way in reverse, but anything added to first machine would pop up as 'new track' when second machine is scanned and then get added back to iTunes on first machine (which results in a duplicate entry / two files in stack end point in iTunes) and this double file would then be replicated to second machine etc. To avoid there would need to be a way to check what is in the iTunes stack on first machine when scanning second machine, and only copy to add file if matched file is not found on first machine. If you can think of a way of doing this loop-back before copying file to 'add to iTunes' on first machine I'd be very interested to know how... :)
glawrie
 
Posts: 6
Joined: Mon Sep 09, 2013 6:07 am

I would look into some specialized software to do a two-way sync. It's a different kind of problem with its own set of issues so I'd look for something built especially to deal with that.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support