method to get location of last picture taken? - LUA Scripting - CHDK Forum supplierdeeply

method to get location of last picture taken?

  • 3 Replies
  • 3776 Views
method to get location of last picture taken?
« on: 29 / November / 2008, 16:17:26 »
Advertisements
is there a way to get the path to the last saved photo? seems like it would be a useful function.

as it is, i'll poke through the various directories as needed. i'll go over my assumptions to see if they match up with what others have experienced.

images are saved with directories inside of the DCIM directory. These directories are named '100CANON' and the prefix number increases by 1 for every ten thousand images saved. i assume this will continue until '999CANON' is reached. At this point, perhaps it goes to '100CANON' rather than '001CANON'

of course, if you start to hit against these limitations, you've taken 9 million pictures. my project takes one pic every fives minutes resulting in 105k images. while i'm not concerned with eclipsing 9m images, i will regularly exceed 10k images and my script needs to be prepared for this.

---

my solution for working with images in different directories
-get list of items in DCIM dir
-grab last item of list, fooDir
-get list of items inside fooDir
-grab last item inside of fooDir
-move to my own dir in DCIM, barDir
-rename last item inside barDir
-hope that eye-fi will find the resulting file and deliver it to my Mac

---

also wonder if there's a way to reset the incremented file names

*

Offline reyalp

  • ******
  • 12742
Re: method to get location of last picture taken?
« Reply #1 on: 29 / November / 2008, 18:46:26 »
You can use get_exp_count() to get the current exposure counter. %/10000 will probably give you the image number part (there may be situations where it varies, but it works on my cam). I'm not sure if you can pull the directory number out of it or not. If you look at core/raw.c, platform/generic/shooting.c and platform/<yourcamera>/shooting.c you can see how these values are obtained.

We could make more of this available from lua very easily. Adding get_parameter_data looks like a good idea.

As I said elsewhere, you should probably not depend on directory listings being in any particular order. os.listdir returns them in whatever order the OS does, and this is normally unspecified. They may frequently show up in sequential order, but I doubt this is always the case. If you want to find the most recent, iterate through them with stat.

BTW, it looks like I'll get string lib checked in today, which will greatly simplify working with directories and file names.
Don't forget what the H stands for.

Re: method to get location of last picture taken?
« Reply #2 on: 29 / November / 2008, 21:51:01 »
i just removed directories '100CANON' and '101CANON' - file start at 100CANON/IMG_0001.JPG again.

let me know when string lib is checked in, i'd love to start using it.

thanks.

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: method to get location of last picture taken?
« Reply #3 on: 30 / November / 2008, 01:46:51 »
makktime, there is a setting in Canon menu: camera setup - File numbering.
When on "auto reset" it will always re-start from 0 when you delete images.
Also, do not rely on the "last" folder (i.e. the one you find last), they can easily get mixeud up if yuo selectively delete images.

You should search the numerically highest folder that fits into the nameing scheme.

as for the naming format, see Wikimedia Error and the pages linked to from that page


 

Related Topics