Uploading photos with OSX webdavΒΆ

I'm now using OSX Finder's webdav support for uploading photos to my plone website. The generic ATContentTypes photoalbum view suits me just fine . I had just two problems with this:

  • OSX Finder leaves '._name-of-image.jpg'-like temporary files in plone.
  • The only info is the filename, so the title is the same as the filename: name-of-image.jpg.
  • Update 2006-05-19: Stefan Holek has the solution for the .DS_store files that webdav leaves around. (I missed that problem).

I've written a small helper script that goes through my photo directory that removes the temporary files. It also changes the title of the files if the title is the same as the id: it removes the .jpg extension and it replaces the - and _ with a space: instant good titles, assuming you name your files in a sane way. That last one is a good idea anyway as it is important for google.

Here's the short script:

   # We do our work in '/plone/photos'
  # OSX webdav leaves files starting with '._', kill them off.
  # Finally, give files with title=id a new title, removing .jpg,
  # dashes, underscores, etc.
  LOCATION = '/plone/photos'

  catalog = context.portal_catalog
  image_brains = catalog(Type='Image',
  print "Found %s images." % len(image_brains)
  for image_brain in image_brains:
      id = image_brain.id
      title = image_brain.Title
      image = image_brain.getObject()
      if id.startswith(REMOVE_START):
          print "Removed %s" % id
      if id == title:
          title = title.replace('.jpg', '')
          title = title.replace('.JPG', '')
          title = title.replace('-', ' ')
          title = title.replace('_', ' ')
          print "Renamed %s to %s" % (id, title)

  return printed

Note that I don't have a digital camera yet. I'm mostly scanning old photos at the moment, primarily for my own enjoyment, but also as others might like the photos. The family photos are of course only interesting for my family, but for instance the train part part is also intended as a target for google: people searching for just the specific locations that I photographed. The locations are specific, but the amount of googlers is big :-)

(Old imported comments)
"changing filename title" by newbie on 2006-11-10 12:30:27
Will this work if i say upload a bunch of txt files via webdav.At present when i do upload the links to the pages show as abc.txt which is horrible. how can i adapt this and incorporate so that any .txt files have the extension stripped off..

or am i confused. please help been looking at how to do this forever
"How do I install the helper script?" by mike combs on 2006-11-06 08:32:34
This looks great, and I could tweak it to do other things, too. Would you give me a pointer to docs on where and how to install a helper script?

"Comment lost" by Reinout van Rees on 2006-05-09 20:33:23
Somebody commented on this item, but the comment got lost between quills and a qcommentmoderation or so. Sorry! If you want, you can re-post.
blog comments powered by Disqus
vanrees.org logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):