Python Forum
|SOLVED] Glob JPGs, read EXIF, update file timestamp?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
|SOLVED] Glob JPGs, read EXIF, update file timestamp?
#1
Hello,

My digital camera has no GPS, so I sometimes take pictures with my smartphone when I need to get geotagged pics.

Problem is, I noticed the time on the camera on my last trip was about 1h ahead than the time on the smartphone which is correct since set from the GSM network.

So, to make it easier to create a slideshow, I need to write a Python script to update the file time on all the pics that were taken with the camera, and substract 1h so they're about the right time.

Pseudo-code:
Glog *.jpg including subdirs
	Read EXIF
	If no GPX //Camera, not smartphone
		Substract one hour
		Update timestamp

Would someone have some code to share?

Thank you.

---
Edit: Almost there:

#pip install pathlib
from pathlib import Path
#pip install exifread
import exifread, sys

for mypath in Path('c:/my/path/').rglob('*.jpg'):
	p = Path(mypath)
	p = p.resolve()
	with open(p, 'rb') as f:
		tags = exifread.process_file(f)
		if "GPS GPSLatitude" in tags:
			print("GPS: ", p)
		else:
			print("NO GPS")
Reply


Messages In This Thread
|SOLVED] Glob JPGs, read EXIF, update file timestamp? - by Winfried - Oct-20-2021, 01:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [SOLVED] Correct way to convert file from cp-1252 to utf-8? Winfried 8 803 Feb-29-2024, 12:30 AM
Last Post: Winfried
  Recommended way to read/create PDF file? Winfried 3 2,872 Nov-26-2023, 07:51 AM
Last Post: Pedroski55
  python Read each xlsx file and write it into csv with pipe delimiter mg24 4 1,431 Nov-09-2023, 10:56 AM
Last Post: mg24
  read file txt on my pc to telegram bot api Tupa 0 1,107 Jul-06-2023, 01:52 AM
Last Post: Tupa
  Timestamp of file changes if a share mapped to a server…. tester_V 34 3,916 Jul-04-2023, 05:19 AM
Last Post: tester_V
  parse/read from file seperated by dots giovanne 5 1,105 Jun-26-2023, 12:26 PM
Last Post: DeaD_EyE
  Formatting a date time string read from a csv file DosAtPython 5 1,254 Jun-19-2023, 02:12 PM
Last Post: DosAtPython
  How do I read and write a binary file in Python? blackears 6 6,517 Jun-06-2023, 06:37 PM
Last Post: rajeshgk
  Loop through json file and reset values [SOLVED] AlphaInc 2 2,101 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
  Read csv file with inconsistent delimiter gracenz 2 1,196 Mar-27-2023, 08:59 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020