[SOLVED] Delete folder when one filetype removed

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

Moderator: Mr_Noodle

Hi All,

Trying to figure out a way to remove a folder, once a particular file (type) is removed;

Downloading series to watch offline, via Plex, including metadata files (banners, subtitle files, .nfo file, etc).
Once watched, I delete via Plex.
However, Plex only deletes the video file, leaving the rest of the files behind.

Is it possible to setup a rule (or set of) in Hazel, to delete a parent folder (after a short period, to ensure not impacting folders being created), if no file of a type exist within it?

Thanks in advance for any help

Regards
Mark
Last edited by QuaCKeReD on Fri Nov 14, 2014 7:49 pm, edited 1 time in total.
QuaCKeReD
 
Posts: 8
Joined: Thu Nov 29, 2012 12:47 pm

Re: Delete folder when one filetype removed Thu Nov 13, 2014 3:59 pm • by Mr_Noodle
Hold down option while clicking the + button to create a nested condition. There, you can set the target of its condition to "all of its sub-files". Any conditions you add under the nested condition, then, must match all the files/folders within the folder. The actions, should the condition match, still apply to the folder.
Mr_Noodle
Site Admin
 
Posts: 11866
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Delete folder when one filetype removed Fri Nov 14, 2014 6:56 am • by QuaCKeReD
Hi and thanks!

How does this work for subfolders though?

Show Folder
-Series Folder
--Episode Folder
---files

If I use 1st rule as 'if folder, run on folders contents', then How do I action on the parent folder?

Or should I not be using this 1st rule?

EDIT; to add to complication, there is also a sample video file within the episode folders, which isn't removed as part of the delete via Plex :(

So, need to remove a subfolder, if a video file not matching a certain naming is removed.......
QuaCKeReD
 
Posts: 8
Joined: Thu Nov 29, 2012 12:47 pm

Re: Delete folder when one filetype removed Fri Nov 14, 2014 11:06 am • by QuaCKeReD
OK, found the way to do it....bit of a shift in thinking not to have rule run against the files, but only the folder :D

However, after this working OK in test, when put live, it keeps getting errors regards metadata for files......

2014-11-14 15:06:11.377 hazelworker[75434] Atlantis (2013): Rule subfolder matched.
2014-11-14 15:06:11.546 hazelworker[75434] Season 01: Rule Delete sample movie files matched.
2014-11-14 15:06:11.549 hazelworker[75434] [Error] Error during rule evaluation: Received error while trying to evaluate rule Delete 'E??' or 'Season ??' with no movie file on file Season 01
2014-11-14 15:06:11.549 hazelworker[75434] Error while matching rule Delete 'E??' or 'Season ??' with no movie file against file /Volumes/MyBook1/ds411/Media/TV Shows/Atlantis (2013)/Season 01: Could not retrieve metadata for file: /Volumes/MyBook1/ds411/Media/TV Shows/Atlantis (2013)/Season 01/Atlantis.2013.S01E04.720p.BluRay-SHORTBREHD-thumb.jpg
2014-11-14 15:06:11.549 hazelworker[75434] ###main load address: 0x102145000
2014-11-14 15:06:11.549 hazelworker[75434] ###Noodle load address: 0x102258000
2014-11-14 15:06:11.549 hazelworker[75434] ###CK load address: 0x10221d000
2014-11-14 15:06:11.549 hazelworker[75434] (
0 CoreFoundation 0x00007fff87bbe64c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff90f106de objc_exception_throw + 43
2 hazelworker 0x0000000102175bd5 hazelworker + 199637
3 hazelworker 0x0000000102171992 hazelworker + 182674
4 hazelworker 0x00000001021894a6 hazelworker + 279718
5 Foundation 0x00007fff8ebca3da -[NSPredicateOperator performOperationUsingObject:andObject:] + 285
6 Foundation 0x00007fff8ebc9ae2 -[NSComparisonPredicate evaluateWithObject:substitutionVariables:] + 313
7 hazelworker 0x00000001021ab2c5 hazelworker + 418501
8 hazelworker 0x00000001021ab3bd hazelworker + 418749
9 hazelworker 0x00000001021aa069 hazelworker + 413801
10 hazelworker 0x00000001021aa3db hazelworker + 414683
11 hazelworker 0x00000001021b53a6 hazelworker + 459686
12 hazelworker 0x00000001021aa069 hazelworker + 413801
13 hazelworker 0x00000001021b4f7a hazelworker + 458618
14 hazelworker 0x00000001021a85d0 hazelworker + 406992
15 hazelworker 0x000000010217c9cf hazelworker + 227791
16 hazelworker 0x000000010214be91 hazelworker + 28305
17 hazelworker 0x000000010214d728 hazelworker + 34600
18 hazelworker 0x000000010214f750 hazelworker + 42832
19 libdyld.dylib 0x00007fff8ce2a5c9 start + 1
20 ??? 0x0000000000000003 0x0 + 3
)
QuaCKeReD
 
Posts: 8
Joined: Thu Nov 29, 2012 12:47 pm

Re: Delete folder when one filetype removed Fri Nov 14, 2014 4:57 pm • by Mr_Noodle
That means that there's no Spotlight metadata for that file. You need to check your Spotlight configuration. Make sure that the file doesn't fall under Spotlight's privacy settings. If need be, try re-building the Spotlight index (google for it as there are different ways of doing it).
Mr_Noodle
Site Admin
 
Posts: 11866
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Ahhh, yes, disk was excluded from spotlight as was used for backups.

Sorted, thank you!
QuaCKeReD
 
Posts: 8
Joined: Thu Nov 29, 2012 12:47 pm


Return to Support