Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import os
from datetime import datetime
# Downloaded files from Google Photo have time in UTC.
# I want to change them to use my local timezone.
tzdiff = 3600 * 9 # my timezone is +09:00
for f in os.listdir('.'):
if '.JPG' in f or '.jpg' in f:
stinfo = os.stat(f)
x = datetime.fromtimestamp(stinfo.st_mtime).strftime("%Y%m%d_%H%M%S")
print f, stinfo.st_mtime, stinfo.st_atime, x
# if you want to embed date into filename
# os.system('mv "%s" "%s_%s"' % (f, x, f)) # TODO: better rename function
# if you want to change atime and mtime
#os.utime(f, (stinfo.st_atime + tzdiff, stinfo.st_mtime + tzdiff))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.