Erase CRW/CR2/DNG files without corresponding JPG - page 3 - Feature Requests - CHDK Forum  

Erase CRW/CR2/DNG files without corresponding JPG

  • 79 Replies
  • 51502 Views
Re: Erase JPG along with corresponding CRW - done
« Reply #20 on: 29 / February / 2008, 14:39:13 »
Advertisements
Deleted
« Last Edit: 22 / April / 2008, 12:55:45 by Barney Fife »
[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye

*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Erase JPG along with corresponding RAW - done
« Reply #21 on: 03 / March / 2008, 12:22:31 »
It is working now regardless which folder you stored your RAW or JPG files. It will find them in any folder inside DCIM.

I struggled with it for days until I discovered you ALWAYS have to close the folders with closedir(). The compiler doesn't warn you and you think your code is simply wrong. I will never forget to include this bloody command.

It works as follows:

First, you delete the outtakes in playback mode (using Canon's interface).
Then, to delete the corresponding RAW files, you go to CHDK File Browser, select DCIM folder, push left button to display the popup menu and select "Purge RAW". A warning will ask you to confirm and voila! You have regained some SD space.

This feature will search through all the folders in DCIM looking for a RAW file (CRW/CR2 prefix or file extension) and if it finds one then will look for its JPG partner anywhere inside DCIM (comparing the 4 digit number assigned by the camera). If it is not found, the RAW file is erased.

I forgot to take some shots of the screen, I will post some tomorrow. Don't tell Nikon I'm using their camera with the only puropose of showing CHDK in action.

See reply #31
You can try it here. Remember this is NOT an official build. The purpose should be testing the "Purge RAW" feature only. Do not use it with important shots. I think it should be tested in all cameras first. because deleting files is always a sensitive operation.

allbest-w-a460-100d-78.zip - 0.21MB
allbest-w-a5xx-all.zip - 0.62MB
allbest-w-a6xx-all.zip - 1.32MB
allbest-w-a7xx-all.zip - 0.49MB
allbest-w-g7-all.zip - 0.84MB
allbest-w-ixus-all.zip - 1.24MB
allbest-w-s2is-all.zip - 0.63MB
allbest-w-s3is-100a-78.zip - 0.21MB


Any comments/suggestions will be appreciated.

This is the function:

Code: (c) [Select]
static void fselect_purge_cb(unsigned int btn) {

    DIR             *d,  *d2,  *d3,  *d4;
    struct dirent   *de, *de2, *de3, *de4;
    char            sub_dir[20], sub_dir_search[20];
    char            selected_item[256];
    int             i, found=0;

    if (btn==MBOX_BTN_YES) {
        sprintf(current_dir+strlen(current_dir), "/%s", selected->name);
        d=opendir(current_dir);
        while ((de=readdir(d)) != NULL) {
            if (de->name[0] != '.' && de->name[1] != '.') {//If item is a file
                sprintf(sub_dir, "%s/%s", current_dir, de->name);
                d2=opendir(sub_dir);
                while ((de2=readdir(d2)) != NULL) {
                    if (de2->name[0] == 'C' || de2->name[9] == 'C') {//If file is RAW (Either CRW/CR2 prefix or file extension)
                        d3=opendir(current_dir);
                        while ((de3=readdir(d3)) != NULL) {
                            if (de3->name[0] != '.' && de3->name[1] != '.') {//If item is a file
                                sprintf(sub_dir_search, "%s/%s", current_dir, de3->name);
                                d4=opendir(sub_dir_search);
                                while ((de4=readdir(d4)) != NULL) {
                                    if (de2->name[4] == de4->name[4] && de2->name[5] == de4->name[5] &&//If the four digits of the Canon number are the same
                                        de2->name[6] == de4->name[6] && de2->name[7] == de4->name[7] &&
                                        de4->name[9] == 'J' && !(de4->name[0] == 'C' || de4->name[9] == 'C' || de4->name[0] == 0xE5)) {//I file is JPG and is not CRW/CR2
                                        started();
                                        found=1;//A JPG file with the same Canon number was found
                                    }                                 
                                }
                                closedir(d4);                 
                            } 
                        }
                        closedir(d3);
                        if (found == 0) {
                            sprintf(selected_item, "%s/%s", sub_dir, de2->name);
                            remove(selected_item);
                            finished();
                        }
                        else {
                            found=0;
                            finished();
                        }                             
                    }
                }
                closedir(d2);
            }
        }
        closedir(d);
        i=strlen(current_dir);
        while (current_dir[--i] != '/');
        current_dir[i]=0;
        gui_fselect_read_dir(current_dir);
    }
    gui_fselect_redraw = 2;
}

Yes, I know, 4 nested while loops, ugly.

Cheers!




« Last Edit: 05 / March / 2008, 12:58:59 by wontolla »

Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #22 on: 03 / March / 2008, 17:44:14 »
Deleted
« Last Edit: 22 / April / 2008, 12:56:07 by Barney Fife »
[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #23 on: 03 / March / 2008, 18:08:12 »
hm, i tested your build for a620, to no effect. dont know what i'm doing wrong. at least nothing at all gets deleted - not the other way around. will make some more tests during next days.


*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #24 on: 04 / March / 2008, 06:12:16 »
Quote
I'm askeered. Smiley (colloquialism for "scared", "afraid", for the non-english crowd) There's no safety "lock file" or "Purge RAW this folder only!" option?
I've done a lot of thinking and my conclusion is that the best "lock file" solution is having the JPG. If the JPG exists somewhere, the RAW will never be deleted.
On the other hand, as you mentioned, we have the Canon lock. It sets the JPG file as "read only" the same way Windows does. The problem is I have no clue how to know if a file is "read only" in C language, let me keep researching or see if somebody has a hint.
But as I said, there is little point to know if the JPG is "read only" because the moment THERE IS a JPG, the function won't erase the RAW file, no matter if it is "read only" or not.
I also tried protecting the RAW directly using the CHDK File Browser marking feature: If the RAW is marked, it won't be erased even if there is no correspondent JPG. But when you go back to DCIM folder the files are no longer marked.
Conclusion: I am also askeered from the user point of view, but I still have no idea how to program the "lock file" option.

Quote
I'm going to have to make a "Wontolla's Builds" folder now. I'm losing track of whose stuff I'm testing lately.
Jeje me too!, I have a mess. I tried Jucifer's configurable menu yesterday. There is something knew in this forum almost every day! Remember to put the Wontolla folder under Tests folder since it is not a usable build.


Quote
hm, i tested your build for a620, to no effect.
Thanks PhyrePhox, I knew there would be problems. Can you elaborate in what you are doing?

Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #25 on: 04 / March / 2008, 07:07:39 »
Deleted
« Last Edit: 22 / April / 2008, 12:56:28 by Barney Fife »
[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye

*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #26 on: 04 / March / 2008, 08:31:22 »
Now I am pissed off!  >:(            <- note this is the first time I use one of this yellow faces so I'm really pissed off!

I must have done something wrong when generating builds for every camera, it's the first time I do it.

This is much worse than GrAndsenberg uncertainty principle, this is Murphy's Law. But well, when they opened Disneyland nothing worked too right?

Let me try again tonight, I will need another bag of coffee. Keep those folders of yours for latter Barney...I'll be back 8)

Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #27 on: 04 / March / 2008, 09:02:30 »
Deleted
« Last Edit: 22 / April / 2008, 12:56:49 by Barney Fife »
[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye


*

Offline Jucifer

  • *****
  • 251
  • [A710IS]
Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #28 on: 04 / March / 2008, 10:10:13 »
Jeje me too!, I have a mess. I tried Jucifer's configurable menu yesterday. There is something knew in this forum almost every day!

The custom user menu is fingalo's, not mine... speaking of which; new day, new stuff. trunk-r314-mod: get_file_counter + faster_menu_navigation

*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #29 on: 05 / March / 2008, 12:27:42 »
@PhyrePhox and Barney
I tried on my camera they very same files I uploaded and they work!
My guess is you didn't execute the Purge RAW in DCIM folder, I mean, while the cursor is highlighting the folder.
I noticed the Purge RAW option always displays in the popup menu regardless it's a file or folder highlighted. So last night I worked in the code and now it considers all possibilities and situations when the user executes the Purge RAW feature (partly to solve Barney's concerns).  Now if you execute the command in a non allowed item it will cancel the purging and display a window saying so. I will post detailed explanations of this new version of Purge RAW.

Thanks for helping me debug this thing.

Errata:
Quote
The custom user menu is fingalo's, not mine...
That is right, I meant/shoud've said: "Jucifer's modifications to Fingalo's custom menu."

 

Related Topics