Rename photos during download from camera - on Linux?

5

1

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.

Torben Gundtofte-Bruun

Posted 2009-12-19T12:06:52.777

Reputation: 16 308

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 – 2009-12-30T09:30:25.160

Answers

0

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.

Torben Gundtofte-Bruun

Posted 2009-12-19T12:06:52.777

Reputation: 16 308

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 – 2010-02-22T01:33:15.727

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 – 2010-08-09T14:37:22.577

1

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

dag729

Posted 2009-12-19T12:06:52.777

Reputation: 1 894

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 – 2009-12-19T16:44:48.173

1Digikam will do custom renaming, and via KIPI plugins will integrate with Picasa. Dig deeper with Digikam, it should meet all your requirements. – SleighBoy – 2009-12-21T20:47:23.690

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 – 2009-12-28T08:16:22.643

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 – 2009-12-29T08:07:07.130

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 – 2009-12-29T14:36:55.287

Don't be sorry - I am thankful for your detailed assistance! This shows that I would probably be better off with native apps after all. If I were a programmer, I'd sit down and write something like "when camera is detected then download all images to path config%1 and rename all files according to pattern config%2, then unmount camera". – Torben Gundtofte-Bruun – 2009-12-29T18:35:17.567

0

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.

Mikael Ohlson

Posted 2009-12-19T12:06:52.777

Reputation: 101

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 – 2010-08-06T12:09:21.310

0

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 http://imagebin.org/index.php?mode=image&id=77701

SleighBoy

Posted 2009-12-19T12:06:52.777

Reputation: 2 066

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 – 2009-12-31T15:09:57.070

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 – 2009-12-31T15:18:56.770