Rename by Creation Date, Area and City? (Exiftool, Geocoder)

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

Moderator: Mr_Noodle

Hi everyone, first post here! I’m noob to this, so I hope I’m posting in the right place.

I’m trying to write a shell script within Hazel to rename a lot of pictures and movies by Creation Date and Area & City. For example:
Filename input: IMG_0057.jpg
Intended Filename output: 2020-03-09 IMG_0057 (Studio City, Los Angeles).jpg

I can extract the GPS coordinates with Exiftool, but I can’t figure out how to pass the coordinates to Geocoder automatically to reverse geocode and then back to rename? (For Geocoder I'm using http://www.rubygeocoder.com/)
Here are the commands I have found so far:

Extract Creation Date with Exiftool and rename to start of file
exiftool -P -d %Y-%m-%d" "%%f\
'-filename<${CreateDate;}.%e' \
"$1"

Outputs: ”2020-03-09 IMG_0057.jpg”


Extract GPS Position with Exiftool
exiftool -gpsposition -n -c %.8f ”$1”

Outputs: ”59.3428694444444 17.8776916666667”


Reverse geocode GPS Position with Geocode
Geocode 59.3428694444444 17.8776916666667

Outputs:

Latitude: 59.3428923
Longitude: 17.8774578
Full address: Blackebergsbacken, Blackebergs gård, Blackeberg, Bromma stadsdelsområde, Stockholms kommun, Stockholm County, Region Svealand, 168 52, Sweden
City:
State/province: Stockholm County
Postal code: 168 52
Country: Sweden
Map: https://www.openstreetmap.org/?lat=59.3 ... 5&layers=M


Do any of you know how to extract the area and city from here? Would like to have the area ”Blackeberg” and the city ”Stockholm”. If City is empty (like it is here), I'd like to have the State/County instead, so it's more likely to be renamed.


How do I combine these lines in Hazel so they can work together?

I know there probably are a couple of blanks that need to be filled here, I would be super appreciative for any help on how to write this to make this work!!

Thank you so much in advance for your help, time and knowledge!

All the best,
Emanuel
email
 
Posts: 1
Joined: Mon Mar 09, 2020 7:28 pm

I think you'd have to do that in a script. While you might be able to get that text back into Hazel and do a "matches" on it, I think having fallbacks when certain fields are empty is extra logic that can't be done in Hazel so easily.
Mr_Noodle
Site Admin
 
Posts: 8522
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support