Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

So I really like Shotwell and I've been using it for about half a year now.

The only problem, there is no export function, and I grouped all my events and named them.

Is there any script or plugin out there I could export all of them into a folder structure like 2012_02 Event XY?

share|improve this question
add comment

3 Answers 3

Okay, since I didn't modify the pictures in Shotwell I'm fine with this little script:

from pysqlite2 import dbapi2 as sqlite
import os
import shutil

targetdirectory = "/home/dan/pictures new/"

db = sqlite.connect('photo.db')
cur = db.cursor()
cur.execute('SELECT strftime("%Y_%m", datetime(PhotoTable.timestamp, "unixepoch")) ||" "|| EventTable.name, PhotoTable.filename FROM PhotoTable LEFT JOIN EventTable ON PhotoTable.event_id = EventTable.id')
for row in cur:

    dir = os.path.dirname(targetdirectory + str(row[0]) +"/")
    if not os.path.exists(dir):
            os.makedirs(dir)
    try:
        if os.path.exists(str(row[1])) and not os.path.exists(targetdirectory + str(row[0]) + "/" + os.path.basename(str(row[1]))):
            shutil.copyfile(row[1], targetdirectory + str(row[0]) + "/" + os.path.basename(row[1]))
    except UnicodeEncodeError:
        print "Error: " + str(row[0])

I think it is really important to have an option to switch to another tool if you want to :)

share|improve this answer
    
I installed python-pysqlite2, saved script as executable export.py in my Pictures dir and ran it in terminal. I receive the error File "./export.py", line 9, in <module> cur.execute('SELECT strftime("%Y_%m", datetime(PhotoTable.timestamp, "unixepoch")) ||" "|| EventTable.name, PhotoTable.filename FROM PhotoTable LEFT JOIN EventTable ON PhotoTable.event_id = EventTable.id') pysqlite2.dbapi2.OperationalError: no such table: PhotoTable. Do you know how to resolve this? Best, –  Rasmus Mar 12 '13 at 10:16
    
Having placed the script in my Pictures folder, I had to change line 7 and point it to the Shotwell DB: db = sqlite.connect('/home/user/.local/share/shotwell/data/photo.db') . Then it worked, but has problems with event or files names with non-ascii characters. First produces File "./export.py", line 11, in <module> dir = os.path.dirname(targetdirectory + str(row[0]) +"/") UnicodeEncodeError: 'ascii' codec can't encode character u'\xf8' in position 14: ordinal not in range(128), second produces Error: 201x_0y DestinationFolder. Can this be circumvented? Else it works very nicely! –  Rasmus Mar 12 '13 at 11:26
    
Adding # coding=utf-8 as first line does not help. –  Rasmus Mar 12 '13 at 12:23
add comment

There is now a shotwell export script based on Dan's example. It will dump the whole shotwell media library to a directory.

Call it like this to match your needs:

shotwell-export --filename "{y}_{m} {event}/{file}"

Disclaimer: it's written/adapted by me. Includes fixes for unicode problems and adds flexibility though arguments.

share|improve this answer
add comment

You cannot export Folders directly however, you can open a Folder> Select all (Ctrl+A) and Export (Shift+Ctrl+E) > to > Location. (naming the folder)

I did find a script which may be adapted from https://github.com/johey/shotup

The Read me states:

Shotup is a tool for exporting a photo gallery from Shotwell, to a browsable online gallery.

share|improve this answer
    
Note that this tool (and similar scripts out there) cannot export photos you've modified within Shotwell. –  MrEricSir Mar 9 '12 at 0:47
    
A good comment from the Developer himself. –  Ringtail Mar 9 '12 at 0:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.