Create folder structure using image -XMP location data

Started by GavinSmith, April 21, 2020, 09:42:05 PM

Previous topic - Next topic

GavinSmith

Only just started playing with today and is an awesome powerful tool so many many thanks to the developer.

Fyi: I am running on my Synology NAS

I am wanting to create a folder structure based off image location data.

Output of one of my images
exiftool -a -XMP-iptcExt:LocationCreatedProvinceState -XMP-iptcExt:LocationCreatedCity -XMP-iptcExt:LocationCreatedCountryCode -XMP-iptcExt:LocationCreatedSublocation -s IMG_0229.JPG

[XMP-iptcExt]   LocationCreatedCity             : Rotorua
[XMP-iptcExt]   LocationCreatedCountryCode      : NZ
[XMP-iptcExt]   LocationCreatedCountryName      : New Zealand
[XMP-iptcExt]   LocationCreatedProvinceState    : Bay of Plenty
[XMP-iptcExt]   LocationCreatedSublocation      : Lake Tikitapu (Blue Lake), Whakarewarewa


Example folder structure
/volume1/photo/2016/06/Rotorua

I know this works
exiftool '-Directory<DateTimeOriginal'  -d '/volume1/photo/%Y/%m' /volume1/InHomeMedia/ImagesToFile

Now a want to add in LocationCreatedCity and have tried a number of different permutations of the command all resulting
In something like this /volume1/photo/2016/06/$76Q6O~W

exiftool '-Directory<DateTimeOriginal' -d '/volume1/photo/%Y/%m/<${XMP-iptcExt:LocationCreatedCity}' /volume1/InHomeMedia/ImagesToFile

Is this possible or would I need to create a script to set the full directory and pass into exiftool

If anyone could guide me in the right direction I would be much appreciated.

Gavin

Phil Harvey

Hi Gavin,

The -d option argument can only contain strings and % tokens.

If you want to include values from any tags, they must go on the right hand side of the "<" operator when copying to Directory.  I think you want something like this:

exiftool '-Directory</volume1/photo/${DateTimeOriginal}/${XMP-iptcExt:LocationCreatedCity;}' -d '%Y/%m' DIR

In the above example, I have moved "/volume1/photo/" from the -d argument to the RHS of "<", although it would work fine where it was.

I have also added a semicolon to remove dangerous characters in case they exist in the city name.  See the documentation on the advanced formatting feature for more details.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

GavinSmith

Works just perfectly and has answered my other questions.

Thanks heaps Phil.

I have donated you some money.

Regards,
Gavin

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).