condition for parent folder

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

Moderator: Mr_Noodle

condition for parent folder Tue Mar 19, 2013 6:30 am • by Graf_Wetter
Hi,

I need a folder to be triggered only if its parentfolder contains no single files but only folders (with files in it).
Can this be done ?

Thanks,
JP
Graf_Wetter
 
Posts: 45
Joined: Thu Aug 25, 2011 7:18 am

Re: condition for parent folder Tue Mar 19, 2013 1:08 pm • by Mr_Noodle
I can get most of the way there:
Code: Select all
If (all) are met for (enclosing folder)
    If (all) are met for (all subfiles)
        Kind is Folder
        Subfolder level is X


This will match if the parent folder only contains folders. X is a subfolder depth of the contents of these folders. For instance, if the enclosing folder's contents (where these folders are) are at level 3, then you want to put 4 as X.

Doing another nest to test if those folders only contain files won't be allowed as it requires nesting (subfiles) within (subfiles) which will cause a huge resource drain.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: condition for parent folder Tue Mar 19, 2013 2:01 pm • by Graf_Wetter
doesn´t work so far.

this is the folder and the rule.

Image

As there is just a folder ("Subfolder1") in "folder" but no files on this level, "Subfolder1" should be matched, but it isn´t. Tried it with several values for X.
Graf_Wetter
 
Posts: 45
Joined: Thu Aug 25, 2011 7:18 am

Re: condition for parent folder Thu Mar 21, 2013 11:52 am • by Mr_Noodle
Ok, I'm a bit confused what you are asking. I don't think you mean the parent folder at all but instead want to match folders directly. If that's the case, then don't use "its enclosing folder". Also, you need to do "Run rules on folder contents" in a separate rule matching folders in general. There's no need to go into a folder in this case if you are going to throw it away anyways. The rules should look something like:

Code: Select all
Rule #1:

If (all) match for (all of its subfiles)
    Kind is Folder
Move to Trash

Rule #2:
If (all) match for (file being matched)
    Kind is Folder
Run rules on folder contents


This will remove any folders that only contain folders, at whatever level they appear at. Note that this may be very resource intensive since it's doing a double-tree traversal, once for each rule.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: condition for parent folder Thu Mar 21, 2013 5:40 pm • by Graf_Wetter
Sorry for the confusion.
"Move folder to trash" shouldn´t be there.

Ok, that´s what I want to do in detail:

-An external workflow produces single pdf-files, some of them are part of the same job, lets say:
job1#1.pdf - job1#10.pdf
job2#1.pdf - job2#10.pdf
job3#1.pdf - job3#10.pdf

30 single files of 3 different jobs.

They all arrive in the same folder, within about 1 minute.
I call this the BASE-FOLDER, it is the one watched by Hazel.
A rule on this folder triggers the incoming files and sorts them in subfolders within the BASE-FOLDER.

-BASE-FOLDER

--SUBFOLDER_JOB1
---job1#1.pdf - job1#10.pdf

--SUBFOLDER_JOB2
---job2#1.pdf - job2#10.pdf

--SUBFOLDER_JOB3
---job3#1.pdf - job3#10.pdf


These new SUBFOLDERS now are triggered by a rule that combines the single pdf-files to one downsized combined pdf,
done with a script that starts ghostscript to do the work.
The most important thing with this rule is that it has to wait till all of the single-pdfs of one job are sorted in, that it doesn´t start to early.
So far I have done this with a "date last modified not in the last 2 minutes" condition on the SUBFOLDERS.
This works sometimes, but:
It happens, that the single-pdfs are very, very large so that all of the single-pdfs of one job can be up to 1 GB or more of data size.
In these cases the ghostscript-rule runs for a long time, sometimes up to 15 minutes.
During these busy minutes all other Hazel rules run very slowly, sometimes they stop completely until the ghostscript rule has finished.
So it happens that a SUBFOLDER only gets the first few files of the job sorted in, whereas the rest of the files is stuck in the BASE-FOLDER because of the delay described above.
When ghostscript has finished all other rules restart or start, so does the next ghostscript-combine, probably of a still incomplete SUBFOLDER.
One solution could be to increase the "date-last modified" time, but that would on the other hand delay all smaller and so faster jobs as well.
As far as I know, a defintion of priority of rules isn´t possible, which could be a solution as well.
So my idea was to start the execution of the ghostscript-rule depending on the occurrence of files:
It should start only if the BASE-FOLDER has no incoming files anymore, if they are all sorted in in their subfolders.
That would guarantee that all job-files are complete and ready to be combined.
Graf_Wetter
 
Posts: 45
Joined: Thu Aug 25, 2011 7:18 am

Re: condition for parent folder Fri Mar 22, 2013 3:28 pm • by Mr_Noodle
You might want to search the forums as there have been other people doing some sort of job queuing with Hazel.

One thing to try is to have the files moved to a common folder which another Hazel process watches. That way, the process running the scripts is separate from the one feeding the files into the folder.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: condition for parent folder Wed Apr 03, 2013 9:04 am • by Graf_Wetter
I did some forum´s search but didn´t find anything that solves my problem.
So please let´s forget all the background of my problem an focus on my initial question:
Is it possible with Hazel to watch Folder_A and to hold rules an Folder_B (and C ...) as long as File_Z is in Folder_A,
but start rules an Folder_B (and C ...) immediately after File_Z has been moved to Folder_B
so that Folder_A contains only subfolders but no more single files.
(the Subfolders_B and _C only contain files, no additional subfolders)

HOLD rules on Folder_B and _C:
Image

START rules on Folder_B and _C:
Image
Graf_Wetter
 
Posts: 45
Joined: Thu Aug 25, 2011 7:18 am

Re: condition for parent folder Thu Apr 04, 2013 4:43 pm • by Mr_Noodle
I'm not totally clear on what you are trying to do. Are you saying not to process files in Folder_B if there is a non-folder file in Folder_A? Are Folder_B and Folder_C fixed or do the rules that run on those folders also run on any additional folders you add to Folder_A?

Because of some current limitations with nesting and such, you'll probably need to write some sort of script to do this type of thing or come up with some other way of doing this. In a future version, I will be addressing some of the issues with nesting (including allowing nesting to go a level deeper) which might allow you to do this but for now a script is the way to go.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support