Tuesday, December 27, 2011

Importing photos from F-Spot in Picasa

Gnome users know F-spot, a photo management software for Gnome.
I used to use F-Spot for a while and my photo library of almost 13 000 photos is organized with the following directories: Year/Month/Day.
Importing all of this into Picasa could be as simple configuring Picasa to watch the old F-Spot photos directory.
However, I wanted my photo library to fit Picasa's naming conventions which is one directory named Year-Month-Day and all the photos of that day inside.

What follows is the code of a small Python script I wrote to do the job.

How to use the script?

 - Copy paste the code in a file named convert2picasa.py;
 - Put this file at the root of your old photo library;
 - Make the file executable with chmod +x convert2picasa.py.

Run it in a terminal.
Once finished, you will notice a new directory named Picasa in your old photo library. This is where all of your photos have been copied following the Picasa naming convention. Therefore you can now simply cut and paste its content in your Picasa library directory!


#!/usr/bin/env python

import os
import shutil

print 'Creating picasa output directory...'
except OSError:

print 'Copying your Year/Month/Day organized photo library to a Year-Month-Day organized library into the picasa directory...'
for dirname, dirnames, filename in os.walk('.'):
    dir_components = dirname.split('/')[1:]
    if len(dir_components) == 3:
        dest_dirname = '-'.join(dir_components)
        dest_dirname = "./picasa/{0}".format(dest_dirname)
        except OSError:
            print "Processing {0}...".format(dest_dirname)
            for f in filename:
                source_file = "{0}/{1}".format(dirname, f)
                dest_file = "{0}/{1}".format(dest_dirname, f)
                print "Copying {0} to {1}...".format(source_file, dest_file)
                shutil.copy2(source_file, dest_file)

1 comment:

  1. Blackjack Casino - Hollywood, FL - JM Hub
    The casino features five blackjack 안산 출장샵 tables, 전주 출장안마 seven rows, and 부산광역 출장안마 five roulette tables, making it 동두천 출장마사지 one of the largest and most 구리 출장마사지 elegant casinos in the world. The hotel