Created
February 4, 2023 19:42
-
-
Save sigilioso/521cdba6a717fb51d859c04cb06c9c3f to your computer and use it in GitHub Desktop.
Set creation date for a set of pictures (one second date difference)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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