Skip to content

Instantly share code, notes, and snippets.

@KonradIT
Created January 28, 2019 17:41
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 KonradIT/2c188ddd86402ae674429c56ee5d236f to your computer and use it in GitHub Desktop.
Save KonradIT/2c188ddd86402ae674429c56ee5d236f to your computer and use it in GitHub Desktop.
import os
import json
import subprocess
from dateutil.parser import parse
from datetime import datetime
DIR="." #current directory
HOUR="09" #hour to match
for file in os.listdir(DIR):
if file.endswith("JPG"):
p = subprocess.Popen("exiftool -FileModifyDate " + file, shell=True, stdout=subprocess.PIPE)
out, err = p.communicate()
stripped_date = str(out.decode("UTF-8")).replace("File Modification Date/Time : ","").split("+")[0]
new_date = datetime.strptime(stripped_date, "%Y:%m:%d %H:%M:%S").time()
if str(new_date).split(":")[0] == HOUR:
print("Date: ", stripped_date)
print(file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment