Yesterday, it was time to keep up with an abandoned project. I have an automatic python script that arranges photos in folders by date.
Dimitris Nikolos (@dnikolos) October 10, 2016
# -*- coding: utf-8 -*- from PIL import Image import os import shutil # exists src_dir/hoge.jpg, fuga.png, etc... src_dir = "/Users/name/hoge/" # create dst_dir/yyyymmdd/ dst_dir = "/Users/name/fuga/" if os.path.exists(dst_dir) == False: os.mkdir(dst_dir) for root, dirs, files in os.walk(src_dir): for filename in files: try: image = Image.open(os.path.join(root, filename)) # 36867 : EXIF DateTimeOriginal date = image._getexif() yyyy, mm, dd = date[:4], date[5:7], date[8:10] yyyymmdd_dir = os.path.join(dst_dir, str(yyyy) + str(mm) + str(dd)) if os.path.exists(yyyymmdd_dir) == False: os.mkdir(yyyymmdd_dir) dst = os.path.join(yyyymmdd_dir, filename) if os.path.exists(dst) == False: shutil.copy2(os.path.join(root,filename), dst) except Exception as e: # .DS_Store must Die print filename + ' is fail.'
I wanted to make a GUI for it. I was thinking of a transition to openFrameworks since it will have straightforward image display and I know how to detect keystrokes there. Plus, I will be able to create an executable to share it with my friends.
But it’s time to learn some things about Tkinter and how to detect keys in Python. And it’s definitely time to built a Windows app with python and tkinter. I’ll stick with Python for now and see how that goes.