Hazel pattern for matching pairs of files (e.g. MP3 + PDF)?

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

Moderator: Mr_Noodle

I have a Dropbox folder that MP3 recordings get dropped into and get processed automatically to transcribe them by an online transcription provider (Otter). Once the transcription is done, a PDF of the transcript is dropped into the same folder. For example, myfile.mp3 will eventually result in myfile.pdf showing up.

I'd like both of these files to get moved to a different folder once that processing has completed.

Is there a way to write a Hazel rule(s) that will only trigger once a pair of files show up with the same base name but two different suffixes (e.g. myfile.mp3 and myfile.pdf)?
felciano
 
Posts: 30
Joined: Sat Feb 23, 2013 5:44 pm

Look up nested conditions in the manual. Using those, you can do something like:
Code: Select all
If (all) are met
    Extension is mp3
    If (all) are met for (any file in the same folder)
        Name matches (name)
        Extensions is pdf


This will match the file if it's a pdf if it has another file with the same name, but an mp3.

The problem here is that once you move the pdf, the mp3 will no longer have the pdf to match against. It might be best to move the mp3 first (reverse the conditions above so that it's matching the mp3 if there's a corresponding pdf), then move any pdf file you find later.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:It might be best to move the mp3 first (reverse the conditions above so that it's matching the mp3 if there's a corresponding pdf), then move any pdf file you find later.


Thanks this was the hint I needed. In case anyone else runs into this, here's the full config that worked:

Rule 1: Move MP3 that has matching PDF
Code: Select all
If (all) are met
    Extension is mp3
    Name matches (name)
    If (all) are met for (any file in the same folder)
        Name matches (name)
        Extensions is pdf
Then
    Move to <folder>


Rule 2: Move PDF with no other same-named file
Code: Select all
If (all) are met
    Extension is pdf
    Name matches (name)
    If (none) of the following conditions are met for (the current file or folder)
        If (all) are met for (any file in the same folder)
            Name matches (name)
            Extensions is mp3
Then
    Move to <folder>
felciano
 
Posts: 30
Joined: Sat Feb 23, 2013 5:44 pm


Return to Support