(view source code of getlocation.bat as plain text)
@ECHO OFF
SETLOCAL
IF "%~1"=="" GOTO Syntax
IF "%~1"=="/?" GOTO Syntax
IF NOT "%~2"=="" GOTO Syntax
IF NOT EXIST "%~1" (
ECHO.
ECHO ←[0;1;31mERROR:←[0m File not found
GOTO Syntax
)
exiftool.exe >NUL 2>&1
IF ERRORLEVEL 1 (
ECHO.
ECHO ←[0;1;31mERROR:←[0m EXIFTool.exe not found
GOTO Syntax
)
FOR /F "tokens=2 delims=:" %%A IN ('exiftool.exe -a -G -gpslatitude "%~1"') DO CALL :Calculate Latitude "%%~A
IF "%Latitude%"=="" (
ECHO.
ECHO ←[0;1;31mERROR:←[0m No EXIF data or no GPS values in EXIF data
GOTO Syntax
)
FOR /F "tokens=2 delims=:" %%A IN ('exiftool.exe -a -G -gpslongitude "%~1"') DO CALL :Calculate Longitude "%%~A
IF "%Longitude%"=="" (
ECHO.
ECHO ←[0;1;31mERROR:←[0m No EXIF data or no GPS values in EXIF data
GOTO Syntax
)
ECHO %Latitude%, %Longitude%
START "Show on OpenStreetMap" "https://www.openstreetmap.org/?mlat=%Latitude%&mlon=%Longitude%&zoom=16"
ENDLOCAL
EXIT /B 0
:Calculate
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "usebackq tokens=1,3,4 delims=' " %%B IN (`ECHO %~2`) DO (
SET Degrees=%%B
SET /A Minutes = %%C
SET Seconds=%%D
SET Seconds=!Seconds:.=!
SET /A Fraction = 6000 * !Minutes! + !Seconds!
SET /A "Fraction = ( 1800 + 100 * !Fraction! ) / 3600"
)
ENDLOCAL & SET %1=%Degrees%.%Fraction%
GOTO:EOF
:Syntax
ECHO.
ECHO GetLocation.bat, Version 1.00
ECHO Open OpenStreetMap on the GPS coordinates of the specified photograph
ECHO.
ECHO Usage: ←[0;1mGetLocation.bat photo←[0m
ECHO.
ECHO Where: ←[0;1mphoto←[0m is the path to the photograph whose location you want to find
ECHO.
ECHO Notes: Requires Phil Harvey's ExifTool:
ECHO ←[0;1;30mhttps://exiftool.org/←[0m
ECHO The author is in no way affiliated with OpenStreetMap:
ECHO ←[0;1;30mhttps://www.openstreetmap.org/←[0m
ECHO ErrorLevel 1 in case of ^(command line^) errors, otherwise 0.
ECHO.
ECHO Written by Rob van der Woude
ECHO https://www.robvanderwoude.com
ENDLOCAL
EXIT /B 1
page last modified: 2024-04-16; loaded in 0.0053 seconds