Skip to content

Instantly share code, notes, and snippets.

@tsuyukimakoto
Created December 10, 2022 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsuyukimakoto/2ef488c7ff6de135e4aa050adfa4e895 to your computer and use it in GitHub Desktop.
Save tsuyukimakoto/2ef488c7ff6de135e4aa050adfa4e895 to your computer and use it in GitHub Desktop.
# 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