3

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?

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 :)

  • 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
0

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.

0

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.

  • 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
0

The script mentioned in Robert's post works well,(Thanks much!!) but it looks for a table called BackingPhotoTable which does not always exist (maybe created after photos are modified?) If it does not, the export script will fail.

This will create the table and solve the problem. CREATE TABLE IF NOT EXISTS BackingPhotoTable (id INTEGER PRIMARY KEY, filepath TEXT UNIQUE NOT NULL, timestamp INTEGER, filesize INTEGER, width INTEGER, height INTEGER, original_orientation INTEGER, file_format INTEGER, time_created INTEGER)

The default path for the photo.db does not seem work, but specifying it in a parameter does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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