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

Erase CRW/CR2/DNG files without corresponding JPG

  • 79 Replies
  • 56817 Views
*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Erase JPG along with corresponding CRW - done
« Reply #10 on: 25 / February / 2008, 13:06:31 »
Advertisements
Very interesting concerns Barney.

I had not thought about RAW Sum and RAW Avg features! If I recall correctly, they create a NEW file with a NEW Canon number, so it would be erased (if the prefix is CRW/CR2). From the top of my head, one way to solve this is that the function never deletes WAV files. Adding this to the second if in the code would do the trick.

Code: (c) [Select]
ptr->name[9] != 'W' &&
The only drawback is you won't be able to automatically get rid of unwanted sound recordings.

edit: I was wrong. When using Sum/Avg feature, the generated WAV file gets the Canon number from the last RAW file. As there is a already a JPG assosiated, it won't be purged.




Quote
I'd feel safe using your method if a write-protect-file feature was available
In this case, the write-protect-file feature is the fact that it only erases RAW files without corresponding JPG. I guess if you want to keep certain RAW file you won't erase its JPG in the first place.

But I thing it is a good idea to let the user to somehow protect (lock) manually some files. I will change the code so if you "mark" files in the file browser they won't be erased. That would give the option to, whatever reason, keep the files you want.

Regarding the "lock" command; that would be a very nice addition to CHDK. But I have no clue how CHDK can "know" when a JPG file has been locked in Canon's menus. And also we have to find the way to permanently mark the RAW files as locked. CHDK would have to write that information to a text file or something in the SD card so it remains even if you turn off the camera. May be someone else have an idea on how to do this.
« Last Edit: 27 / February / 2008, 14:28:20 by wontolla »

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Erase JPG along with corresponding CRW - done
« Reply #11 on: 27 / February / 2008, 14:27:51 »
havent analyzed your code yet, but does your function browse all folders looking for corresponding jpg or only the one you start the function in? i think you know why i'm asking, but to people who don't know: sometimes (or everytime if you havent enabled the option) raws arent saved in the same dir as the jpgs. this would mean that raw files might be deleted even though there is a corresponding jpg.

*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Erase JPG along with corresponding CRW - done
« Reply #12 on: 27 / February / 2008, 14:57:36 »
You are right, I was assuming both JPG and RAW files are in the same folder. In my case, I always keep them together but other users may not.

I guess something like this could prevent it: if (conf.raw_in_dir) "start search" else "cancel erase"

I also have to add the option of searching on several folders, not just one.

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Erase JPG along with corresponding CRW - done
« Reply #13 on: 27 / February / 2008, 15:01:59 »
by the way grAnd wrote some useful info on the "different folders for raw & jpgs" problem in this thread: Build 31, SD500 - RAW file directory

*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Erase JPG along with corresponding CRW - done
« Reply #14 on: 27 / February / 2008, 15:24:22 »
Yes, you cannot be 100% sure where the RAW file is going to be located.

It is a known issue in quantum CHDK physics called: "The GrAndsenberg uncertainty principle"

Scientists presume it only happens with the first shot in a fresh SD card. Or when you create manually a new folder and shot again.

Anyways, if we get the function to search all the folders in /DCIM, this is no problem.

Re: Erase JPG along with corresponding CRW - done
« Reply #15 on: 27 / February / 2008, 21:29:11 »
Deleted
« Last Edit: 22 / April / 2008, 12:54:58 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 - done
« Reply #16 on: 28 / February / 2008, 11:16:56 »
I found this attribute in stlib.h file:
Code: (c) [Select]
DOS_ATTR_RDONLY /* read-only file */Is not beeing used anywhere else in the code. I guess it was intened to be used the way Barney suggested.
Give me some time, I've never dealed with read/write files and stuff

*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Erase JPG along with corresponding CRW - done
« Reply #17 on: 29 / February / 2008, 12:17:47 »
Ok, now I can searh in every folder inside DCIM with this code:

Code: (c) [Select]
int main() {
   
    DIR             *d, *d2;
    struct dirent   *de, *de2;
    int             found=0;
    char            sub_dir[256];
    char            current_dir[20]="DCIM";

        printf("Opening main folder %s", current_dir);
        d=opendir(current_dir);
        de=readdir(d);
        while (de) {//For all folders in DCIM
            if (de->d_name[3] == 'C' && de->d_name[4] == 'A') {//Is the item a folder?
                printf("\nFound a Canon sub folder");
                sprintf(sub_dir, "%s/%s", current_dir, de->d_name);
                printf("\nOpening Canon sub folder %s", de->d_name);
                d2=opendir(sub_dir);
                de2=readdir(d2);
                while (de2) {
                    if (de2->d_name[0] == 'C' || de2->d_name[9] == 'C' && !(de->d_name[0] == '.' || de->d_name[1] == '.' || de->d_name[2] == '0')) {//Is the item a RAW file?
                        printf("\nFound RAW file %s", de2->d_name);

                    }
                de2 = readdir(d2);
                }
                printf("\nExit sub folder %s", sub_dir);
            }
            de = readdir(d);
        }
        printf("\nExit main folder %s", current_dir);
       
        getch();
}

Note that this code does not run in the camera but in the PC. I got tired of loading the SD card from the PC to the camera every time. Once this works it is only a matter of copy it to the trunk an change 2 or 3 lines. (Of course you have to use the same arm gcc compiler for execute in the PC).

Well, the problem of RAW files in different location than the JPG can be solved by duplicating this code. One time to search ALL of the RAW files and the second to search ALL the corresponding JPGs. But my concern is as follows: AFAIK the bug GrAnd mentioned involves ONLY ONE RAW file in a different folder so I wonder if a complete DCIM tree search is worth for ONLY ONE file. I think not.

Because of this I was thinking to write the code to detect when the user has specified a special folder for RAWs in the CHDK RAW menu and use that folder in the search. On the other hand, if the user is writing the RAWs in the same folder than JPGs the problem is already solved with the first piece of code in this thread. This way we avoid a double search in the DCIM tree. I hope I am clear with my limited English.

I'd appreciate your input.

Re: Erase JPG along with corresponding CRW - done
« Reply #18 on: 29 / February / 2008, 13:56:15 »
Deleted
« Last Edit: 22 / April / 2008, 12:55:22 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 - done
« Reply #19 on: 29 / February / 2008, 14:30:24 »
Thanks Barney for the support.

I fully agree with you about save RAW and JPG fies in the same folder.

I just posted my previous comment to see if there was any user who does otherwise. So the effort of doing an "erase in all folders" function was worth.

I will try to do both: An "erase RAW in current folder" and an "erase RAW in all folders". So the user can chose.

Sorry for my english, I am going home and have no time to correct it in Word.

Cheers!

 

Related Topics


SimplePortal © 2008-2014, SimplePortal