Created
December 10, 2022 06:58
-
-
Save tsuyukimakoto/2ef488c7ff6de135e4aa050adfa4e895 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Update exif information of image files in yyyy_mm_dd folder to yyyy_mm_dd 10:00:00 | |
# need exiftool <- brew install exiftool | |
from pathlib import Path | |
import subprocess | |
def dt_fmt(dir_name): | |
yyyy, mm, dd = dir_name.split('_') | |
return f'{yyyy}:{mm}:{dd} 10:00:00' | |
pth = Path('.') | |
for subdir in pth.iterdir(): | |
if subdir.is_dir(): | |
for file in subdir.glob('*'): | |
cmd = [ | |
"exiftool", | |
f"-datetimeoriginal='{dt_fmt(str(subdir))}'", | |
f"{file}" | |
] | |
subprocess.call(cmd) | |
# delete original file made by exiftool | |
# for subdir in pth.iterdir(): | |
# if subdir.is_dir(): | |
# for file in subdir.glob('*'): | |
# if str(file).endswith('_original'): | |
# file.unlink() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment