Skip to content

Instantly share code, notes, and snippets.

@Rachel030219
Created February 11, 2023 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rachel030219/0f098e561f413e67e9d17298a6e66461 to your computer and use it in GitHub Desktop.
Save Rachel030219/0f098e561f413e67e9d17298a6e66461 to your computer and use it in GitHub Desktop.
Adding time zone to JPEG photos dragged on the file, in order to fix the sorting / time zone error when photos without GPS and time zone are uploaded to Google Photos with an IP from a different location than the photo is taken.
@echo off
if "%*" == "" goto usage
rem get the time zone from the system
echo Getting time zone
for /F "eol=; tokens=2 delims=^(^)" %%I in ('wmic timezone get caption /format:list') do (
set "UTCTimeZone=%%I"
)
set "UTCTimeZoneOffset=%UtcTimeZone:UTC=%"
echo Time zone: %UTCTimeZoneOffset%
rem modify the photos, leaving RAW files etc unaffected
set modified=
for %%x in (%*) do (
set fileNeedModify=
if "%%~xx" == ".JPG" set fileNeedModify=1
if "%%~xx" == ".jpg" set fileNeedModify=1
if defined fileNeedModify (
set modified=1
echo Adding time zone to "%%~x"
exiftool.exe -EXIF:OffsetTime*=%UTCTimeZoneOffset% "%%~x"
)
)
if defined modified (
echo Adding finished, press any key to remove original files, or close this window to cancel
@pause
rem delete the original files
for %%x in (%*) do (
echo Removing %%~x_original
del "%%~x_original"
)
echo Removing original files finished, press any key to exit
@pause
exit
) else (
echo No need to modify, press any key to exit
@pause
exit
)
:usage
echo Please drag and drop the photos you want to modify on the batch file, press any key to exit
@pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment