Sort Into Subfolder if multiple files with same match

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

Moderator: Mr_Noodle

Hello,

This may be something simple but I cant seem to think of a way to do this or find and answer.

I have pdf report files that I am using Hazel to look inside and pull information from to rename the file using the Serial Number, Customer, Date etc. found in the header of the pdf. This works great but I potentially have two different types of reports (diagnostic vs repair) that can have the same Serial Number, Customer, Date information etc. in the header.

When I am in the field I save these files to a dropbox location that Hazel will organize once I'm back my computer in order to keep the file names and folders consistent for each machine model. Currently after the files are renamed they are sorted into folders titled with the appropriate machine model based on the serial number pulled from the file. If I happen to run both a diagnostic and repair test while in the field and save both to the dropbox folder and they files are renamed and contain the same serial number I want to sort them into a folder titled with the machine serial number.

This would be easy to sort them into machines serial number folders regardless but I only want them to be sorted if another file exists in the directory containing the same serial number in its name.

Sort only if another file exists in the same folder with same serial number.
jfisher
 
Posts: 55
Joined: Sat Feb 25, 2017 7:47 pm

You would probably need to use a separate rule which sorts into subfolder. You could use a nested condition to match on "any file in the same folder" to check for the existence of the other file.

The problem here is that once you sort the first file, it won't exist for the second file to know that it should be sorted. There might be several ways around this. One is to also check if the folder to sort into exists in the above "any file in the same folder" condition. Alternatively, you might be able to do one pass where you set tags on the files, then another to sort the tagged files.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thanks, the theory makes sense but how would I create a match to look for a Serial Number that Hazel doesn't know exists at that point? Matching using a serial number mask just grabs everything and dumps it in the first folder. Serial numbers are ###@#### format. It seems like I would need to match against a list or have ever new serial as a matching criteria.

Image
jfisher
 
Posts: 55
Joined: Sat Feb 25, 2017 7:47 pm

If the serial number format is fixed like that, you can specify it in the pattern. If you create a custom attribute to match that serial, when you re-use it in the same rule, it will have to match that same value.

For example, if you have a serial number of 123@4567 and you match that in one condition, subsequent conditions that use that same attribute will also have to match 123@4567.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thank you, that was easier than I thought and works well.
jfisher
 
Posts: 55
Joined: Sat Feb 25, 2017 7:47 pm


Return to Support

cron