Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On Windows, I'm using this feature (right-hand text) of the excellent cam2pc software to download images&videos from my camera and rename them in the same step. I haven't found any software for Linux that does the same, or does it as good. Suggestions please?

Details and requirements:

  1. I am using Picasa for everything after the download and I want to keep using it.
  2. I want a better download functionality than what Picasa offers.
  3. I know that some tools can do batch renaming after the download, but that's limited to those inside one folder. I want to specify the renaming scheme before the download, in a one-step process.
  4. Must run on PCLinux 2009.2 (Mandriva variant with KDE).
  5. Should autodetect that the camera has been plugged into the pc.
  6. Must download JPG and AVI files.
  7. Must support a user-customizable pattern for the downloaded files, like
    path/year/year-month-day hour-min TOPIC serial#.lowercase-extension
    e.g. photos/2009/20091218 1214 Skiing with friends 001.jpg
    (In cam2pc, that would look like %Y%m%d %h%u %P %{num:3}.%{ext})

By the way, I'm new to Linux and not a programmer, so I am hoping that solutions already exist that aren't too technical, or well documented.

share|improve this question
Isn't there some way to trigger a shell script when an USB drive is mounted? Such a script could then search for a /DCIM/ folder and download any media in there, then unmount the drive. That would help. (I then need to learn some shell stuff of course.) – Torben Gundtofte-Bruun Dec 30 '09 at 9:30

sorry if I'll tell you something that could be obvious, but: have you tried if that application can run under WINE?

Just because I saw the website of cam2pc and it has a lot of features that, for sure, could be reproducted on any Unix machine, using many little tools (for example cron, wget, diff, mkdir, mv and so on), but it requires to have some skills and/or a little of spare time.

While I'm here, I would suggest you to take a look at DigiKam and at F-Spot as well that, although don't have all the features you are requiring, maybe could help you to do some useful tricks.

Hope that helps.

EDIT: I tried cam2pc inside my box (Ubuntu 9.04 64bit) under WINE and it worked like a charm! Here's a screenshot where you can see my desktop with cam2pc running and a terminal with the outputs of uname -a and wine --version:

enter image description here

share|improve this answer
I am running XP inside VirtualBox for some Windows apps - and yes, cam2pc is one of them. But it would be nice to have that natively instead. I've seen that DigiKam and F-Spot are already installed and I've tested them. As you say, they can do some neat things but it's not what I was looking for. I know the purpose of the tools you mention but not how to use them. I wouldn't mind sort-of building something myself, if I knew how. With the versatility of Linux, perhaps someone has already made a recipe for setting this up (using those tools or others) -- I just need a pointer to that recipe. – Torben Gundtofte-Bruun Dec 19 '09 at 16:44
Digikam will do custom renaming, and via KIPI plugins will integrate with Picasa. Dig deeper with Digikam, it should meet all your requirements. – SleighBoy Dec 21 '09 at 20:47
Is there a tool to import albums and captions from Picasa? I didn't find a plugin to upload into Picasa Web Albums, which is something I really need - does one exist? (Digikam kept crashing for me; I've now reinstalled it and it runs. Hence these questions.) – Torben Gundtofte-Bruun Dec 28 '09 at 8:16
Wine: I was also able to install cam2pc using Wine, and browse and also rename existing images. However, cam2pc did not detect that a camera was plugged in and hence couldn't download any new images, nor could it play AVI videos (though the sound did play). Also, going to Tools|Options made the app freeze. Was this successful on your test installation? – Torben Gundtofte-Bruun Dec 29 '09 at 8:07
I confirm that >it could not play AVI videos and >going to Tools|Options made the app freeze but I can't test the camera recognition (I haven't a cam now). I am sorry: I hoped in something better... – dag729 Dec 29 '09 at 14:36

Give Digikam a solid go. If you had troubles with it, post here and I'll do what I can to help you out. Take a look right here, I think this image indicates it meets your requirements. Those directory names are by choice, they could be however you wanted. If you're already with KDE, Digikam is the answer, no doubt about it.

alt text

share|improve this answer
My questions are in an earlier comment. Q1: Is there a tool to import albums and captions from Picasa? (I'd hate to have to retype captions.) Q2 about a plugin to upload into Picasa Web Albums seems to be answered by the screenshot; I'll take a look. – Torben Gundtofte-Bruun Dec 31 '09 at 15:09
On first look, the batch renaming can only handle files once they are downloaded, and can only handle renaming inside one album at a time. Also, the renaming pattern does not allow subdirectories (like /2009/20091231/pics_go_here_001.jpg). Do you know a solution for this? – Torben Gundtofte-Bruun Dec 31 '09 at 15:18
up vote 0 down vote accepted

A custom solution requires a little programming -- I need to write a shell script:

  1. Use the find command to see if the newly mounted USB drive contains media files;
    if no media files are found, then abort the script.
    find "/media/disk/dcim" -iname "img*.*" -type f

  2. Use the read command to prompt for a topic. (Equals %P in the question.)

  3. Find the timestamp of the oldest media file.
    ls -GgtR --full-time --time-style +"%Y%m%d %H%M" *.png | tail -1 | cut -c21-34

    • Hints:
      -GgtR = hide group and owner, sort by time, list Recursively.
      tail = keep only the last 1 line of the output.
      cut = keep only the characters 21-34.
  4. Use mkdir to create a new folder based on that date and topic.

  5. Use the find command with the -execdir option to find all media files,
    then move (mv) each hit to the new folder,
    then use jhead to rename each hit according to each file's timestamp.

  6. Optional: Use the umount command to unmount the USB drive.

  7. Set up Linux to execute this script when an USB drive is mounted. The detection of the USB drive (or camera) varies depending on the Linux variant; refer to OS-specific documentation. Or just run the script manually...

I'll need to spend invest some hours in learning bash commands, and also in learning how Linux mounts drives.

share|improve this answer
I originally scripted up a solution. It has worked fine for over a year. Unfortunately it did bad things two days ago under an unexpected context (unmounted file share). I think I've managed to recover all of my images now (thanks PhotoRec!). I am still looking for a very general purpose open source program so that I can share finding bugs with everybody else... ;). – kwutchak Feb 22 '10 at 1:33
I would appreciate a comment along with that downvote. What didn't you like about this answer? How is this answer not useful? – Torben Gundtofte-Bruun Aug 9 '10 at 14:37

This answer is just a complement to torbengb's answer. I use exiftool for mass-renaming/-moving photos.

It is able to extract the date and time of the photo from the exif-data and to create directories and names pretty much any way you want.

Here is a quick-link to the FAQ/manual entry about renaming files.

share|improve this answer
Yes, I tested that too, and it is good. But since it deals with EXIF, of course it only reads photos and not videos. So that still leaves the videos on the camera, needing a separate solution. – Torben Gundtofte-Bruun Aug 6 '10 at 12:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .