Changing the names of images on the SD card - Script Writing - CHDK Forum

Changing the names of images on the SD card

  • 9 Replies
  • 5785 Views
Changing the names of images on the SD card
« on: 08 / October / 2012, 21:42:20 »
Advertisements
Hi All,

I have 2 cameras that I am setting up to make a scanner (this could equally apply to stereo images).  The cameras are PowerShot A3200 IS.

I want to give my scripts the ability to control the names of the images that are stored on the SD cards as the pictures are taken. 

So, I would like the first image on Camera 'A' to be something like 'img001A.jpg' and on camera 'B' it could be 'img001B.jpg'.

After I call the 'shoot' command in the script, is there any way that I can control what that image is called.

Thanks,

David.

Re: Changing the names of images on the SD card
« Reply #1 on: 08 / October / 2012, 22:55:37 »
In the event you don't get a better answer (or any answer) to this question,  I will chime in to say there is no easy or obvious way to do this with CHDK.   The general subject has been discussed many times on the forum with no good solution although there have been some hacks for particular circumstances ( like upload the images right after they are created and rename them on your PC).
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14125
Re: Changing the names of images on the SD card
« Reply #2 on: 08 / October / 2012, 23:07:05 »
You can rename images in a lua script with os.rename(), but if your name doesn't follow the canon naming convention (IMG_nnnn.JPG) then the Canon firmware will no longer see them. This means you won't see them in review mode, and won't be able to transfer them using the USB cable and standard software.
Don't forget what the H stands for.

Re: Changing the names of images on the SD card
« Reply #3 on: 08 / October / 2012, 23:13:22 »
You can rename images in a lua script with os.rename(), but if your name doesn't follow the canon naming convention (IMG_nnnn.JPG) then the Canon firmware will no longer see them. This means you won't see them in review mode, and won't be able to transfer them using the USB cable and standard software.
I'll bite .. how do you determine the name of the image you want to rename ?  ( i.e. the most recent image taken I suppose ...)
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14125
Re: Changing the names of images on the SD card
« Reply #4 on: 08 / October / 2012, 23:18:59 »
I'll bite .. how do you determine the name of the image you want to rename ?
Painfully.

You can just list all the files, and rename any that don't match the expected pattern. This will run into memory problems if you get too many images on the card.

You may be able to figure out the appropriate number form the exposure counter, but this may not work on all cameras.

If you start with the card empty, after the first shot you can figure out the file number by listing the directory, and then just increment from there on. You can also start from 0 looking for IMG_nnnn.JPG.
Don't forget what the H stands for.

Re: Changing the names of images on the SD card
« Reply #5 on: 09 / October / 2012, 03:34:22 »
Wouldn't be a better idea to add some special EXIF tags to images (for example using TagMe script) and then do renaming on computer?
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: Changing the names of images on the SD card
« Reply #6 on: 09 / October / 2012, 08:48:08 »
Painfully.You can just list all the files, and rename any that don't match the expected pattern. This will run into memory problems if you get too many images on the card. You may be able to figure out the appropriate number form the exposure counter, but this may not work on all cameras. If you start with the card empty, after the first shot you can figure out the file number by listing the directory, and then just increment from there on. You can also start from 0 looking for IMG_nnnn.JPG.
Wouldn't be a better idea to add some special EXIF tags to images (for example using TagMe script) and then do renaming on computer?
These are good examples of "some hacks for particular circumstances" in my OP.

In addition, by default each image will have date and time info in its EXIF info.  Assuming the time on both cameras is the same, then a small Perl or Python script on the PC to do the renaming might be the simplest way out of this.  Even if the time stamps are off, the script could be setup to use an offset (auto-calculated or user defined).
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Changing the names of images on the SD card
« Reply #7 on: 09 / October / 2012, 09:45:57 »
Thanks for the replies.  It looks to me as if this might be possible, in a roundabout kind of way. 

Changing the EXIF tags might be the best route, as there could be hundreds of images on the card and would run into memory problems with listing and parsing all the names. 

I wonder whether it might be possible to have a script that might only permits odd or even numbered images.

This could work by setting the start image at IMG_0001.JPG on one camera and IMG_0002.JPG on the second.  In both cases, the script would increment the number of images by 2, instead of the normal 1.

Is this suggestion possible in the CHDK?

Thanks,

David Kane

*

Offline reyalp

  • ******
  • 14125
Re: Changing the names of images on the SD card
« Reply #8 on: 09 / October / 2012, 16:19:34 »
Changing the EXIF tags might be the best route, as there could be hundreds of images on the card and would run into memory problems with listing and parsing all the names. 
This has to iterate over the selected files too, so if it works then renaming would work too. It looks like it uses numeric ranges rather than trying to list them all.

Simple listing is probably OK for hundreds of files, thousands could be problematic.
Quote
This could work by setting the start image at IMG_0001.JPG on one camera and IMG_0002.JPG on the second.  In both cases, the script would increment the number of images by 2, instead of the normal 1.

Is this suggestion possible in the CHDK?
No, we don't have control of the image counter. It's stored in a flash param, but given how central it is to the camera firmware operations, messing with it seems like a dubious proposition.

The simplest workaround seems like doing a batch rename after each download. In the original post you asked for something like IMGnnnnA and IMGnnnnB, it should be very easy to download everything from a single camera to a directory and rename it like that.
Don't forget what the H stands for.

Re: Changing the names of images on the SD card
« Reply #9 on: 09 / October / 2012, 17:44:38 »
At the risk of duplicate posting (because I just made this comment in a different thread) the best tool I've found for manipulating bulk exif information is :

http://owl.phy.queensu.ca/~phil/exiftool/
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics


SimplePortal © 2008-2014, SimplePortal