How to make variable folder?

Started by Bimbam, February 18, 2023, 04:22:14 PM

Previous topic - Next topic

Bimbam

Hello everyone!

I would like to ask for help with the following problem. I wrote a bash script that reads the possible GPS data from the file, which I use for an OSM query, and thus I get a myCity variable.
I want to use this myCity variable as a library, so I create this library. How can I tell EXIFtool to take this into account?
What I would like:
bash variable: cityName="Budapest"
IMG_354187452.jpg > ./Budapest/Huawei MAR-LX1A/2022/2022-05/PIC_20220518_153512.jpg
You should know that in the first step, I filter the files to be processed once with the EXIFtool.
exiftool -ext jpg -if 'not $datetimeoriginal' '-filename=./noData/%f%+c.%e' -execute -if 'not $GPSPosition' -d '%Y/%Y-%m/PIC_ %Y%m%d_%H%M%S%%-c.%%le' '-filename<./noGPS/${make}_${model}/${datetimeoriginal}' -common_args .
But the noData and noGPS folders are already problematic here, because I couldn't enter them as variables either.
It's a joy because bash doesn't even have to check if it exists, because EXIFtool monitors and manages it.
The next step is to extract the GPS data:
    lat="$(exiftool -n -p '$GPSlatitude' "${filename}" 2>/dev/null)"
    lon="$(exiftool -n -p '$GPSlongitude' "${filename}" 2>/dev/null)"
And although this is no a specific question for Exiftool, I will get it the name of the settlement.
cityName="$(curl -s "https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lon}" | jq -r '.address.town, .address.village, .address.city' | grep -v "null" | head -n1)" I would like to use the variable name: ${cityName} obtained in this way in the example outlined.
Currently, bash creates the cityName folder, then a basename loop counter for duplicates, and moves the images into the folder. Later I have to sort it into camera folders within the city name.
Is it possible to solve this somehow using the EXIFtool?

StarGeek

Try How to use bash shell variable in exiftool command, though it might depend upon the type of the shell.  The bash variable needs to have double quotes around it while exiftool variables need single quotes.

Personally, I would suggest two separate passes.  One pass to get the city names and embed that data into XMP:City and/or IPTC:City.  Then a second pass and used the City tag the same way you use Model and Make.

You want to try and call exiftool as few times as possible because exiftool's biggest performance hit is the startup time (see Common Mistake #3).
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Bimbam

Thanks for the information.

Yes. I thought about it too, I just thought it was slow. Let's say it is, but whatever, I made peace with it. And if it's a goose, let it be fat, so I included to picture more information from a temporarily downloaded json file.

However, I found some interesting anomalies. :)

Modjuk, this is not a EXIFtool problem at all.

For example in the picture taken with the phone, the GPS info sometimes displays Georgian, Arabic, Chinese or some unexpected place info.

Although no one went there. However, the names of the created  cities are revealing. And the problem is that if I want to place this (street level), I will only be able to do that one by one, maybe the larger scale will remain. But thank God it affects say 20 out of 3000 images.