Recursing a directory

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

Moderator: Mr_Noodle

Recursing a directory Mon Dec 16, 2013 3:23 pm • by lobstah
Hello all! Hoping that Hazel has the ability to do this:

I have a directory structure which is set up as follow:

studies->[random#sequence]->[scored]->[filename]

Here's what I want Hazel to do. I want it to go in to the studies directory. Then I want it to scan the directories. If there is a new directory, then I want it to go in to the directory (so now it's in the [random#sequence] directory. Once in there, it can either go in to one of 3 directories [john, sally, mary]. If john doesn't exist, then it looks for mary. If mary doesn't exist, then it looks for sally. So if one of those 3 exist, it now goes in to that directory [scored]. One in scored, there is one of 3 file names (similar to above, but not those same names). If that file name exists, I want it to copy that file to a different directory, which is named [random#sequence]->[scored]->[filename].

Is this level of complexity/logic something that Hazel could do? Thank you!!
lobstah
 
Posts: 8
Joined: Sun Nov 13, 2011 6:47 pm

Re: Recursing a directory Tue Dec 17, 2013 2:54 pm • by Mr_Noodle
The John-Mary-Sally part is tricky. If it's just those specific 3 folders, you can try something like:

Code: Select all
Rule 1:
    If Name is "John" ...

Rule 2:
    If all are met
        Name is "Mary"
        If all are met for the enclosing folder
            If all are met for any-subfile
                Name is not "John"

Rule 3:
   If all are met
        Name is "Sally"
        If all are met for the enclosing folder
            If all are met for any-subfile
                Name is not "John"
                Name is not "Mary"


To do nested conditions, hold down the option key while pressing the + button to create a new condition. It's a bit ugly but it might work.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Recursing a directory Tue Dec 17, 2013 9:44 pm • by lobstah
Thanks! I'll try that and get back to you!
lobstah
 
Posts: 8
Joined: Sun Nov 13, 2011 6:47 pm


Return to Support