Create a new directory and save next images in it

  • 7 Replies
  • 2234 Views
Create a new directory and save next images in it
« on: 28 / November / 2012, 09:34:07 »
Advertisements
It might be simple but could not find it:
I wish to create new directory at start of a time lapse shot so that session photographs is saved in there (and then on my camera the usual behaviour is to have a new directory automatically created by the camera every 2000 photographs, that is fine).
Also that way I could create a new directory every hour for example.

*

Offline reyalp

  • ******
  • 11264
Re: Create a new directory and save next images in it
« Reply #1 on: 29 / November / 2012, 00:02:14 »
You may be able to do this by using scripted key presses to trigger the "create folder" function in the normal firmware menu.
Don't forget what the H stands for.

Re: Create a new directory and save next images in it
« Reply #2 on: 30 / November / 2012, 11:25:48 »
Thanks for the suggestion Reyalp.
The camera is shooting a time-lapse until tomorrow morning so I'll wait until then to check this for sure.

But as far as I remember (and just checked the manual), the SX150IS "Creat Folder" menu has 2 options only: Monthly or Daily. One cannot just create a new folder at will, it seems.

Re: Create a new directory and save next images in it
« Reply #3 on: 30 / November / 2012, 13:08:38 »
I would try using "os.rename" to move the existing directory to a new name, then "os.mkdir" to create a new directory using the appropriate name the camera expects to find.  Repeat for each time-lapse.
You might not need to even create the new directory -- the camera might do it if it isn't found (even if there was one before).  Should be tested.
If it doesn't work, I'm guessing one of two things will happen:  pictures will be saved in the renamed directory or the camera will give an error or crash.
A810 1.00e


Re: Create a new directory and save next images in it
« Reply #4 on: 30 / November / 2012, 14:26:38 »
SnowL, I would be happy with standard folder naming, I was just looking for a command to force create a new folder instead of waiting next day or month or 2000 photographs.
If I have to give it a name then I have to test and see. I'll do that after my current time-lapse is finished shooting, tomorrow after sunrise.

*

Offline reyalp

  • ******
  • 11264
Re: Create a new directory and save next images in it
« Reply #5 on: 01 / December / 2012, 00:53:29 »
I would try using "os.rename" to move the existing directory to a new name, then "os.mkdir" to create a new directory using the appropriate name the camera expects to find. 
os.rename on a non-empty directory is likely to trash the filesystem. If you go this route, please test carefully on a card without any data that you care about on it, and report back.
But as far as I remember (and just checked the manual), the SX150IS "Creat Folder" menu has 2 options only: Monthly or Daily. One cannot just create a new folder at will, it seems.

edit: Note this may not be true for recent cameras, it's worth testing if you are up for it.
It does look like canon has removed the "create folder now" option that the cameras with non date based folders have. Bummer.
« Last Edit: 01 / December / 2012, 01:16:53 by reyalp »
Don't forget what the H stands for.

Re: Create a new directory and save next images in it
« Reply #6 on: 01 / December / 2012, 17:17:30 »
I would try using "os.rename" to move the existing directory to a new name, then "os.mkdir" to create a new directory using the appropriate name the camera expects to find. 
os.rename on a non-empty directory is likely to trash the filesystem. If you go this route, please test carefully on a card without any data that you care about on it, and report back.
Simply renaming the current image directory to a new name works -- no need to create a new directory.  This works on A810/1.00e with latest 1.2 build:
Code: [Select]
d = get_image_dir()
os.rename(d,d..".A")
sleep(5000)
shoot()
d = get_image_dir()
os.rename(d,d..".B")
sleep(5000)
shoot()
The existing image directory DCIM/113_0112/ contained 2 photos (IMG_0510 & IMG_0511) and got renamed to DCIM/113_0112.A/.  A new picture is taken which is saved in a new automatically created DCIM/113_0112/ which then gets renamed to DCIM/113_0112.B/ and contains IMG_0512.  The last picture is taken and saved in DCIM/113_0112/

The only time I provoked an error using os.rename was when trying to rename a directory that had just been renamed.  In llibtst.lua, I added the following after the commented trename line:
Code: [Select]
tren("A/MDTST0","A/MDTST1")
tren("A/MDTST1","A/MDTST0")
The first tren works but the second one fails and A/MDTST1 is left on the sdcard.

The cameras do not have a set_image_dir (or SetImageFolder) function that I can find, so the only other way I can think of to get images saved in new directory would be to change camera's clock, which also does not have a direct function, so would need to be done by simulating keypresses.

No filesystems were trashed or otherwise harmed while executing these tests.

A810 1.00e

Re: Create a new directory and save next images in it
« Reply #7 on: 01 / December / 2012, 17:35:32 »
Just to note - there can be problems when you try to open or modify any file by CHDK while CANON firmware handles any other file opened. This can cause camera to crash very easily (simmilar thing sometimes happens when you try to run CHDK filebrowser too fast after turning camera on).

I would add a little delay before rename. Just to be more safety ;)
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick


 

Related Topics