Showing posts with label exif. Show all posts
Showing posts with label exif. Show all posts

Sunday, 21 November 2010

Organize your photos by date in nautilus

I already know how to use the exif information in pyhton to group photos in folders by date the picture was taken( see here ). The problem is that you must run the script in a terminal and the script must by in the python path. So I changed it a bit. Now the script can be used in the Nautilus. To group photos in any directory I can select Scripts-> Group By Date.

Tuesday, 2 November 2010

Simple way to organize photos by date

I have a lot of pictures. Like most people today. They were all dumped in one directory. It was very difficult to view them. So I wrote a very short python script that reads from the EXIF date the photo was taken. Create a directory for that date and move the photo in this directory.
Here's the script:
import os
from PIL import Image
import shutil

cdate_tag = 0x9003

files = [f for f in os.listdir('.') if f.endswith('.JPG')]

for f in files:
    if os.path.isfile(f):
        img = Image.open(f)
        date = img._getexif()[0x9003].split(' ')[0].replace(':','_')
        if not os.path.isdir(date):
            os.mkdir(date)
        shutil.move(f,os.path.join(date,f))
        print f,date
        img.fp.close()