Can I examine directory contents? - Script Writing - CHDK Forum  

Can I examine directory contents?

  • 8 Replies
  • 5274 Views
Can I examine directory contents?
« on: 15 / March / 2011, 08:04:19 »
Advertisements
Can I examine the contents of the images directory from an SDM ubasic script? I'd like to find out how many images are already in the directory when I start the camera and later find out if the gphoto2 script I'm running on my computer has removed them.

Re: Can I examine directory contents?
« Reply #1 on: 16 / March / 2011, 13:48:57 »
Can I examine the contents of the images directory from an SDM ubasic script? I'd like to find out how many images are already in the directory when I start the camera and later find out if the gphoto2 script I'm running on my computer has removed them.

No.
Are you interested in just a count of a particular image type, such as JPG ?


Re: Can I examine directory contents?
« Reply #2 on: 16 / March / 2011, 14:13:57 »
Mainly I just want to estimate how long I need to upload_images_for so my computer has a chance to fetch all the images and then delete them to leave lots of room for more, so a count would be all I'd need for my immediate purpose. Might not really matter much since I usually start with an empty directory and could have the script count the number of times it took a photo, but if my time estimates are off the computer might not grab everything, so I'd like to be able to tell if any are left and add more time next time I transfer a batch.

Re: Can I examine directory contents?
« Reply #3 on: 16 / March / 2011, 14:20:21 »
So, a count of JPEG images ?


Re: Can I examine directory contents?
« Reply #4 on: 16 / March / 2011, 14:59:01 »
That would be the minimum I'd need for my one purpose right now, but who know if someone might need something more sometime in the future.

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: Can I examine directory contents?
« Reply #5 on: 16 / March / 2011, 15:55:04 »
So, a count of JPEG images ?
That would be the minimum I'd need for my one purpose right now, but who know if someone might need something more sometime in the future.
You can calculate the number of JPGs using the current UBasic commands as long as you already know the maximum number of JPGs that can be put on your SD card. For example CHDK shows that the maximum number of JPGs I can put on my 4G card is 1203. Since UBasic can tell us the amount remaining, you can simply do a little subtraction to get the number of JPGs on the card. I used a parameter but you could just as well as "hard code" the value in the subtraction line. I would expect it to be accurate to within one JPG (diff would be due to different compression results for JPGs, addition of LOG files, etc). There is also a UBasic command for RAW files, so you could use the same process for them as well. Here's a simple script to play with:

Code: [Select]
@title Test
  @param a Max
  @default a 1203
    x=get_jpg_count
  y=a-x
  print "JPGs on card="y
  end
« Last Edit: 16 / March / 2011, 16:51:32 by SkyWalker9 »

*

Offline reyalp

  • ******
  • 14121
Re: Can I examine directory contents?
« Reply #6 on: 16 / March / 2011, 17:00:46 »
FWIW, CHDK Lua gives you directory and file functions: http://chdk.wikia.com/wiki/Lua#Lua_standard_libraries:_io.2C_os.2C_string.2C_and_math

It would be much more difficult to implement and use in ubasic, since ubasic has no concept of variables that are anything but integers.
Don't forget what the H stands for.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Can I examine directory contents?
« Reply #7 on: 16 / March / 2011, 17:34:52 »
Another possible workaround would be to use the get_free_disk_space command to detect an increase in free disk space (if this command exists in SDM ubasic).


*

Offline zeno

  • *****
  • 891
Re: Can I examine directory contents?
« Reply #8 on: 16 / March / 2011, 19:04:19 »
Back in December 2008 I added string variables to Ubasic (see http://www.zenoshrdlu.com/kapstuff/zexpubdb.html). I added some extra functions to demonstrate the capability - including some primitive directory facilities. Nobody was very interested however - so the project just lapsed.
A570, S100, Ixus 127
Author of ASSIST, STICK, WASP, ACID, SDMInst, LICKS, WICKS, MacBoot, UBDB, CFGEdit

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal