( Nextra | 2023. 02. 12., v – 12:05 )

OK. Már működik, de azt nem tudom hogy megoldható-e hogy ne kelljen 3x végigmenni a mappán? Ugyanis a feldolgozandó json adatokban különböző megnevezések találhatók a helységnevekre.
town, village, city 

#!/bin/bash

noGPSdir="noGPS"

if [ ! -d "${noGPSdir}" ]; then
    mkdir "${noGPSdir}"
fi

searchCity () {
    rename JPG jpg *.JPG 2>/dev/null
    chmod 644 *.jpg
    for files in *.jpg ; do 
        lat="$(exiftool -n -p '$GPSlatitude' "${files}" 2>/dev/null)"
        lon="$(exiftool -n -p '$GPSlongitude' "${files}" 2>/dev/null)"
        if test -n "${lat}" -a -n "${lon}"; then
#            echo "$files - van koordináta"
            cityName="$(curl -s "https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lon}" | jq -r "${secn}")"
            
            if [ ! -d "${cityName}" ]; then
                if [ ! "${cityName}" = "null" ]; then
                    mkdir "${cityName}"
                fi
            fi
            if [ ! "${cityName}" = "null" ]; then
                mv "${files}" "${cityName}"
            fi
        else
#            echo "${files} - nincs koordináta"
            mv "${files}" "${noGPSdir}"
        fi
    done
}

secn=".address.town"
echo "address.town figyelése ***************"
searchCity

secn=".address.village"
echo "address.village figyelése ************"
searchCity

secn=".address.city"
echo "address.city figyelése ***************"
searchCity

#exiftool -r -d '%Y/%Y-%m/PIC_%Y%m%d_%H%M%S%%-c.%%le' '-testname<%-1:D/${make}_${model}/${datetimeoriginal}' .
#exiftool -r -ext jpg -progress -d '%Y/%Y-%m/PIC_%Y%m%d_%H%M%S%%-c.%%le' '-filename<%-1:D/${make}_${model}/${datetimeoriginal}' .

#/usr/bin/halt -p >/dev/null 2>&1