Page 1 of 1

Please Help! Seems like a simple rule but not working???

PostPosted: Thu Feb 04, 2016 9:43 am
by bugmenot
Hello,

I am mucking about with Hazel to see if it is good for my needs but can't for the life of me work out how to get it to do what I consider to be a pretty simple task.

What I want Hazel to do is move a file contained in a folder up to its parent but I only want this to happen if the folder only has one file within it.

Al the moment I have tried:

If | all | of the following conditions are met
If | all | of the following conditions are met for | the current file or folder
sub-file/folder Count | is | 1
Kind | is not | Folder
Any File

Do the following..
Move | to folder | enclosing folder.

Any clue as to how I can do this?

Please note that I have tried placing the recommended include Nested Subfolders Rule beneath, in case that is needed:

If | any
kind | is | Folder
Run rules on folder contents

?????

Re: Please Help! Seems like a simple rule but not working???

PostPosted: Thu Feb 04, 2016 11:55 am
by Mr_Noodle
Note that the formatting in your post doesn't come through so I have to figure out how things are nested. Yes, you will need the subfolder rule to get to the file. In your nested condition, you want to use "enclosing folder" and not the "current file or folder". You want to check the sub-file count of the parent folder, not the file itself. Also, "any file" makes no sense here (it really only makes sense when used by itself).

Re: Please Help! Seems like a simple rule but not working???

PostPosted: Fri Feb 05, 2016 11:03 am
by bugmenot
Hello Mr. Noodle - Thanks for your quick response. I've written scripts before but there's something about Hazel's logic that just doesn't compute with me!

I've added an image of how I think the rule should work which should hopefully illustrate how I'm (incorrectly) tackling the problem.

Image

The Psuedocode would look like this:

If the current folder has exactly one file in it (which is not a folder itself), move this file out of its folder, up one level.

As it stands, the rule in the image above moves the entire folder (with the single file inside) to the enclosing folder.

I read your original reply and I think I'm just not thinking in Hazel's perspective as it didn't make much sense to me. :(

I hope this post helps illustrate where I am coming from at any rate.

And thanks again for your help!

Re: Please Help! Seems like a simple rule but not working???

PostPosted: Fri Feb 05, 2016 11:05 am
by bugmenot
And just in case I somehow screwed it up, here's my Nested Folder Rule.

Image

Re: Please Help! Seems like a simple rule but not working???

PostPosted: Fri Feb 05, 2016 12:00 pm
by Mr_Noodle
Do not use the "Run rules on folder contents" in the rule meant to match the file you want to move. It's in a separate rule for a reason. Also, as mentioned before, the sub-file count only makes sense when matched against a folder. In the pop-up that says "the current file or folder", change that to "the enclosing folder". That should do it.

Re: Please Help! Seems like a simple rule but not working???

PostPosted: Sat Feb 06, 2016 9:41 am
by bugmenot
Mr_Noodle wrote:Do not use the "Run rules on folder contents" in the rule meant to match the file you want to move. It's in a separate rule for a reason. Also, as mentioned before, the sub-file count only makes sense when matched against a folder. In the pop-up that says "the current file or folder", change that to "the enclosing folder". That should do it.


Thanks Mr. Noodle. I got everything working but it has been a bit haphazard -- I checked the log and there was some crashes but after a reboot it's all working fine.

Re: Please Help! Seems like a simple rule but not working???

PostPosted: Mon Feb 08, 2016 1:04 pm
by Mr_Noodle
Glad you got it working now. Can you email in the crashes? I'd be curious to see what they are.

Re: Please Help! Seems like a simple rule but not working???

PostPosted: Wed Feb 10, 2016 8:56 am
by bugmenot
Mr_Noodle wrote:Glad you got it working now. Can you email in the crashes? I'd be curious to see what they are.


Sorry but the logs are gone. It was basically stuck in a loop as it had to work with a bunch of other rules. I just moved the rules around some and the loop stopped. Sorry I can;t be of more help. :/