Rename multiple files from 'Contents' inside a single file?

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

Moderator: Mr_Noodle

Hi, I'm still very new to Hazel (and don't know programming) but I'm getting the hang of it and it's a miracle time saver. I have a rule I'm trying to make that I feel like I'm close on but it''s just beyond my reach in trying to make work.

- I have a folder called 'ALL FILES'

- In this 'ALL FILES' folder there will be sets of 3 files all named the same thing (.mov + .jpg + .txt file) EXAMPLE:
    2016-09-23 17-08-23 F017.jpg
    2016-09-23 17-08-23 F017.mov
    2016-09-23 17-08-23 F017.txt
    2016-09-24 12-29-44.jpg
    2016-09-24 12-29-44.mov
    2016-09-24 12-29-44.txt

- The .TXT files contents contains the 'Pattern' of what each of the 'sets of 3' files SHOULD be named. Example of the .TXT file contents:
_______________
NAME: FIDO
My ID # A4884975
I'll be available on : 10/9/2015 12:00:00AM
______________

In the above example I want to take the number 'A4884975' from the .txt file contents, rename ALL THREE FILES (.mov + .jpg + .txt) to have their filenames be 'A4884975' and move them into a subfolder named 'A4884975'

I currently have this working but only with the .TXT file. It gets renamed - in this case to 'A4884975' and placed in a folder named 'A4884975' but I can't figure out how to have Hazel rename the .MOV & .JPEG files to be called 'A4884975' and move them into the folder named 'A4884975' too.

Any ideas? Maybe it's something simple I'm missing? Would something like 'Rule Conditions' be what I need? The following link shows my current rule that works for just the text file: https://db.tt/JrglhJpP
twistlick
 
Posts: 6
Joined: Mon Aug 29, 2016 10:53 pm

First read this article: https://www.noodlesoft.com/kb/how-to-cr ... onditions/

Now with that in hand, you can try something like:
Code: Select all
  If (all) are met
     If (all) are met for (the enclosing folder)
         If (all) are met for (any sub-file)
             Name is (name)
             Extension is txt
             Contents contain match ...


What this does is check if there's another file in the same directory with the same name, but with the txt extension. The contents match checks the content of that file.

The problem here is if the txt file is processed first, it gets renamed and moved so you need to set this up in two phases where the txt file is not processed unless the other two files are missing (which you can do similarly to the above).
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support