Stop processing a subfolder.

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

Moderator: Mr_Noodle

Stop processing a subfolder. Thu Feb 13, 2014 7:58 am • by mattsh
I'm looking to create a process to clean up a downloads folder. In general terms, it will look like this:

1. Move music to music folder
2. Move images to images folder
3. Move apps to apps folder

At one point, all that will be left in this downloads folder will be folders with movies. I want to go into that folder to remove anything that is not a movie. (jpg, txt, etc). I then do this:

4. Run rules on subfolders
5. Remove the junk

This all works. Now what I want to do is to break out of the subfolder processing and return to the parent folder, the downloads folder. How do I get back to the parent level to continue processing there?
mattsh
 
Posts: 9
Joined: Wed Feb 12, 2014 12:13 pm

Re: Stop processing a subfolder. Fri Feb 14, 2014 4:23 pm • by Mr_Noodle
Not sure if I fully follow but you should consider just doing it in a separate rule.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Stop processing a subfolder. Fri Feb 14, 2014 9:22 pm • by dhy8386
mattsh wrote:I'm looking to create a process to clean up a downloads folder. In general terms, it will look like this:

1. Move music to music folder
2. Move images to images folder
3. Move apps to apps folder

At one point, all that will be left in this downloads folder will be folders with movies. I want to go into that folder to remove anything that is not a movie. (jpg, txt, etc). I then do this:

4. Run rules on subfolders
5. Remove the junk

This all works. Now what I want to do is to break out of the subfolder processing and return to the parent folder, the downloads folder. How do I get back to the parent level to continue processing there?


If the downloads is the top level folder, you should have a run on sub folders as your first rule. Subsequent rules can used to moved the music, images, apps into their respective folders by using the kind attribute. That way, because hazel stops at a rule when its matched, if it doesn't match the kind it will move onward. Therefore, if that downloads folder then has subfolders which contains movies as well as other junk, it will remove the junk based on the kind rules you set and when they are empty with junk, nothing will match below the subfolders rule in essence enabling the whole process to start over from the top level folder of downloads.
dhy8386
 
Posts: 94
Joined: Tue Nov 09, 2010 12:19 pm

Re: Stop processing a subfolder. Tue Feb 18, 2014 3:13 am • by mattsh
Well I guess in simplest terms again, I'm wondering if there's a rule that's the opposite of "run rules on folder contents."

In more complex terms:

Start in the downloads folder.

Move music, images, text to other folders.
The downloads folder now only has folders with movies (and possibly other junk) and movie files.

I now move movies not in folders into a folder of it's own. So Movie A is in a Folder called Movie A, Movie B is in a folder called Movie B, etc. So now at the top level, the downloads folder, there are only folders.

Now I go into the folders and remove anything that is not a movie using the "run rules on folder contents." If a movie folder has image files, trash those. If they have text files, trash those. Now the downloads only has folders, and each of those folders only has movies.

Now I want to do a "stop running rules on folder contents." I want to run rules on the downloads folder again. I want to take each of these folders and move them to new locations. This is the part that doesn't work. Every time I add a new rule, it processes inside the movie folder, not the parent folder, downloads.

So the process simplified is process in the downloads folder, process inside folders in the downloads folder, then return up a level to the downloads folder to process some more. Hope that's clearer...
mattsh
 
Posts: 9
Joined: Wed Feb 12, 2014 12:13 pm

Re: Stop processing a subfolder. Tue Feb 18, 2014 5:03 pm • by Mr_Noodle
If you have a run rules on folder contents rule with "Kind is folder" as the condition, if it's the first rule, it will match every folder. You can't have a rule later which also matches folders since the first rule that matches is the one that gets executed.

You'll need to do something like set a color on the folder when it's done and then don't go into it if that color is set. The problem here is that in the subfolder rule, if you set it to color after doing "Run rules on folder contents", because of a quirk in how the engine processes things, it will color the folder before going into it to run rules. That said, if the process is not interrupted before finishing processing all the subfolders, the other rule to handle folders after being colored will fire at the right time. The only bad situation is if something interrupts/kills the worker process before it's done. In that case, the folder will be colored but the contents have not been finished being processed.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Stop processing a subfolder. Tue Feb 18, 2014 6:06 pm • by dhy8386
I threw together something that will allow you to do this BUT it makes a big assumption if you can live with it -- that if a folder only has 1 file in it, it is a "Good" folder with just a movie file. So your downloads folder can have junk, and the subfolders can have junk, and the scripts will get rid of everything that is not a movie and then move the folders to another destination. This works by adding an additional condition to the run rules on folder contents so that a bad folder is anything with multiple files or folders in it such that by the time the folders are cleaned, they end up with just one file in them (a movie file) and this you can add a final rule to move Kind is Folder to another location (since the original run in subfolders had to match 2 conditions not the one normally used as Kind is Folder.

That was probably convoluted but look at the attached and see if it can help you.

https://mega.co.nz/#!DlpUFR5C!gm0L-devx ... 4hT2BgZlMo
Last edited by dhy8386 on Tue Feb 18, 2014 9:08 pm, edited 1 time in total.
dhy8386
 
Posts: 94
Joined: Tue Nov 09, 2010 12:19 pm

Re: Stop processing a subfolder. Tue Feb 18, 2014 7:42 pm • by Smudge
dhy8386: FYI, you might have uploaded the wrong set of rules. I was curious to see what you did and downloaded them but they don't match to what you have explained in your post.
Smudge
 
Posts: 34
Joined: Mon Jul 15, 2013 10:44 pm

Re: Stop processing a subfolder. Tue Feb 18, 2014 9:08 pm • by dhy8386
Smudge wrote:dhy8386: FYI, you might have uploaded the wrong set of rules. I was curious to see what you did and downloaded them but they don't match to what you have explained in your post.


Thanks. My mistake. Fixed the above link.
dhy8386
 
Posts: 94
Joined: Tue Nov 09, 2010 12:19 pm


Return to Support