Read number of pictures on the card / free space left on the card? - Script Writing - CHDK Forum supplierdeeply

Read number of pictures on the card / free space left on the card?

  • 3 Replies
  • 4898 Views
Read number of pictures on the card / free space left on the card?
« on: 25 / September / 2011, 16:52:57 »
Advertisements
Hi,

is there a script command that can read, how many pictures (i.e. in .jpg format) are currently on the SD card I'm using? I've found get_exp_count, but get_exp_count gives me the number (the prefix) of the currently taken picture (i.e. IMG_1578 => get_exp_count==1578)?
Or, is there a script command that can read, how much space is left on the SD card?
I'm using Canon A590 + CHDK 1342 build.
I'm particularly interested in a command that will tell me if there are currently _any_ pictures on the card.
is_card_empty == 1 => no pictures on the SD card.
is_card_empty == 0 => some pictures on the SD card.
Regards.
« Last Edit: 25 / September / 2011, 16:54:58 by trismarck »

Re: Read number of pictures on the card / free space left on the card?
« Reply #1 on: 25 / September / 2011, 17:02:36 »
You could try get_jpg_count.   Its a bit of a brute force approach and will change with different SD cards but run it once with an empty card to get a starting value.   Hard code that into your script and if the next calls to get_jpg_count are lower then you have pictures on your card.

Ported :   A1200    SD940   G10    Powershot N    G16

Re: Read number of pictures on the card / free space left on the card?
« Reply #2 on: 25 / September / 2011, 17:23:40 »
waterwingz: I've checked get_jpg_count.
The function returns the number of jpg images I can save on the SD card before the card will fill up.
The interesting thing is that I've took two pictures (M3 quality) and the counter decreased only once. So this method is unreliable (or the counter script has bugs?).

*

Offline reyalp

  • ******
  • 14121
Re: Read number of pictures on the card / free space left on the card?
« Reply #3 on: 25 / September / 2011, 17:24:02 »
Or, is there a script command that can read, how much space is left on the SD card?
Yes, get_free_disk_space. get_disk_size will get you the total space.

In lua, you can also use os.listdir to actually list the files and os.stat to get their details.
Don't forget what the H stands for.


 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal