Skip to content

Instantly share code, notes, and snippets.

@sigilioso
Created February 4, 2023 19:42
Show Gist options
  • Save sigilioso/521cdba6a717fb51d859c04cb06c9c3f to your computer and use it in GitHub Desktop.
Save sigilioso/521cdba6a717fb51d859c04cb06c9c3f to your computer and use it in GitHub Desktop.
Set creation date for a set of pictures (one second date difference)
# -*- coding: utf-8 -*-
from glob import glob
from exiftool import ExifToolHelper
from datetime import datetime
from datetime import timedelta
# Requires exiftool and pyexiftool. See: <https://sylikc.github.io/pyexiftool/installation.html#pyexiftool-dependencies>
photos = sorted(glob('**/*.jpg'))
d = datetime.now()
with ExifToolHelper() as et:
for photo in photos:
d = d + timedelta(seconds=1)
et.set_tags(
[photo],
tags={'DatetimeOriginal': d},
params=['-P', '-overwrite_original']
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment