Help with file match and delete in nested folders?

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

Moderator: Mr_Noodle

Hello!

I use Calibre to convert ebooks from (epub, mobi, azw3, etc) to .kepub for use on Kobo Reader.

The files are in /drive/books/author name/bookname/ebook files

I would like to have Hazel monitor (or run once a night etc) and:

IF .kepub exists delete the "epub, mobi, azw3, etc" files.

The files will have the same name and only the extension changes on conversion.

I'm having trouble getting any rules to match or find the files.

Thanks for any help or advice on how to proceed.
deadrubberboy
 
Posts: 3
Joined: Tue Jan 14, 2025 12:52 pm

You'll need to use a nested condition like the following:
Code: Select all
If (all) are met
    Extension is epub
    If (all) are met for (any file in the same folder)
        Name matches (name)
        Extension is kepub


The above will match an epub when there's a kepub file with the same name in the same folder. You can extend this as needed to handle the other cases.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:You'll need to use a nested condition like the following:
Code: Select all
If (all) are met
    Extension is epub
    If (all) are met for (any file in the same folder)
        Name matches (name)
        Extension is kepub


The above will match an epub when there's a kepub file with the same name in the same folder. You can extend this as needed to handle the other cases.


Thank you!

Will this search in sub folders? IE. I make the rules in the top /books folder and it looks in the existing and future added books/author/booktitle folders?
deadrubberboy
 
Posts: 3
Joined: Tue Jan 14, 2025 12:52 pm

Mr_Noodle wrote:You'll need to use a nested condition like the following:
Code: Select all
If (all) are met
    Extension is epub
    If (all) are met for (any file in the same folder)
        Name matches (name)
        Extension is kepub


The above will match an epub when there's a kepub file with the same name in the same folder. You can extend this as needed to handle the other cases.



Clearly I'm doing something wrong. I have many other rules moving files based on extension etc from the same drive... For some reason this one is not working.

When I use the "rules test" I can't even get a green check on "extension is epub". I tried "kind is EPUB" I tried with and without the leading "." - it just won't see it. If I change it to "any file" I get green check. Otherwise I'm all Red X's.
deadrubberboy
 
Posts: 3
Joined: Tue Jan 14, 2025 12:52 pm

Can you post a screenshot of the preview with the extension not matching? Note that you can't upload images here so if you don't have your own cloud service for posting stuff, you can use imgur.com.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support