Name Folder based on the timestamp of its contents

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

Moderator: Mr_Noodle

Hey,

I am trying to organize my photos in dropbox with the assistance of Hazel. How can I have Hazel recognize there is a new folder called "Example Photos" then dig through its contents and add a timestamp to the folder based on the oldest photo or at least a photo that's inside it?

For example, if today is 11/24/2014 and there are two photos in the folder "Example Photos" which are A.jpg shot on 12/12/2012 and B.jpg shot on 11/11/2011. I want the the folder to be renamed "2011-11-11 Example Photos" or at the very least "2012-12-12 Example Photos".

Thanks.
auby1885
 
Posts: 2
Joined: Mon Nov 24, 2014 9:44 pm

Doing the oldest would be a bit tricky. First off, read the sticky article on subfolders as you'll need that rule.

From there, create a rule like the following:
Code: Select all
  If (all) match
    Extension is jpg
    <<< somehow match against date taken and store it in a custom date attribute >>>
    (°date taken) is among the 1 least recent
  Do
    Add tag (°date taken)


That will match the file with the oldest date. There's a big question about how to get that date. If you are talking about the EXIF date taken, you'll need a script to extract that (search the forums) and then export that as a custom token back to Hazel. The rule will set the date as a tag on the file which will be used next.

To handle the folder, you'll need to do something like:
Code: Select all
  If (all) match
    If (all) match for (any of its sub-files)
      Tags match (° file date)
  Do
    Rename (° file date)(name)


To get the sub-condition, you need to hold down option while clicking the + button to create a new condition. This rule will match the folder where it has a file with a tag that matches a date (you'll need to create that custom attribute and set its pattern appropriately). Since the date is stored in a custom date attribute, you can then use it in the renaming pattern.

I suggest studying the above carefully instead of just blindly using it. It's quite tricky and it helps to understand how it works.
Mr_Noodle
Site Admin
 
Posts: 11866
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Actually, I realized you don't need to have two separate rules.
Code: Select all
If (all) match
    If (all) match for (any of its sub-files)
      Extension is jpg
      <<< somehow match against date taken and store it in a custom date attribute >>>
      (°date taken) is among the 1 least recent
Do
    Rename (°date taken)(name)
Mr_Noodle
Site Admin
 
Posts: 11866
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support