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

Erase CRW/CR2/DNG files without corresponding JPG

  • 79 Replies
  • 51670 Views
*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #60 on: 20 / March / 2008, 17:18:04 »
Advertisements
I bet the next working address is 0x0200

Look at the MPOPUP_MASK 0x00FF and MPOPUP_CANCEL 0x0100... ;)
So, there is no gap anymore for adding extra menu items. At least next time these constants should be changed a bit.
CHDK Developer.

Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #61 on: 21 / March / 2008, 15:13:12 »
I tried the build for the SD850 and it did not work for me.  I formatted the card several times, and try autoboot as well as manual CHDK boot.  The blue LED turns on, and the screen goes blank and locks up hard.  Requires battery pull.

*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #62 on: 28 / March / 2008, 15:47:45 »
@ PhyrePhox and rockstar
Thanks for testing and sorry for the late response. I have many things to do lately. You know, the same old story: my sister's racoon ate my card reader and my aunt broke her ankle trying to catch it.

@ PhyrePhox
The camera just dies? Darn, this is a huge step backwards; it already worked in the A560! May be it doesn't work with a lot of files (160 in your case). When I did my tests I always tried with a few only. Please try this new build both with few and lots of files if you can.

@rocstar
Sorry about the problems caused. I don't understand, it works flawlessly in my S3. I hope you dare to try this again, may be first try to erase RAWs in file browser list only, to see if that works, that's a simple loop. Because erase in one folder and erase in DCIM folder takes 2 and 3 nested loops respectively.

It seems I will have to "go back to formula" grrrrrrrrrrr!!!


New builds for people to try (based on Allbest's 48). Please post here if it works or not in your camera. Remember these builds are for testing purposes. Do not use in the field or with valuable pictures. For details on how it works see Reply #31.

allbest-a460-100d-50.zip - 0.22MB
allbest-a5xx.zip - 1.32MB
allbest-a6xx.zip - 1.18MB
allbest-a7xx.zip - 0.52MB
allbest-g7.zip - 0.89MB
allbest-ixus55x.zip - 0.43MB
allbest-ixus65_sd630-100a-50.zip - 0.22MB
allbest-ixus70x.zip - 0.65MB
allbest-ixus700x.zip - 0.44MB
allbest-ixus8xx.zip - 0.73MB
allbest-ixus950_sd850-100c-50.zip - 0.22MB
allbest-s2isx.zip - 0.66MB
allbest-s3is-100a-50.zip - 0.22MB updated 31 March
   S3 diskboot.bin ps.fir In case you can't unzip previous file


Who the heck has been porting CHDK for IXUS? It's getting harder to upload builds for all cameras!


« Last Edit: 31 / March / 2008, 07:28:03 by wontolla »

Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #63 on: 29 / March / 2008, 01:05:29 »
Wontolla,
I tried the a 550, and it worked great!
The SD850 still has the same problem.  Just booting the firmware locks up the camera hard and I have to pull the battery to get it back.  The blue print LED turns on steady.  That's the only thing it does.


Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #64 on: 30 / March / 2008, 07:04:58 »
Hello,

I downloaded the file for the S3IS - but I cannot unpack the zip file.
The a5xx.zip works though, I just tested.
Is it possible that the S3IS file is corrupted?

I'd really like to test the release - thanks for the great work!

obitus

*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #65 on: 31 / March / 2008, 08:29:51 »
@rockstar
Thanks for testing. Well, now we have success with S3 and A550.
Quote
Just booting the firmware locks up the camera hard
So, the problem is when loading the Purge RAW build? When turning on the camera?
Or is it when trying to erase some RAW files in File Browser?
Have you ever build CHDK in your computer? To find the problem in the SD850, one way to go is you make your own build using my diff file.

@obitus
Weird, I just downloaded S3 and I can unpack it. Anyways, I uploaded a fresh zip file and also the "fir" and "bin" files just in case. Thanks for testing.

Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #66 on: 31 / March / 2008, 14:14:29 »
Hello wontolla,

I was now able to download and extract the S3 file.
I have 1 JPG and 1 CRW left with their original names, img_0004.jpg and img_0004.crw
I went to the 100CANON folder, selected "Purge RAW" - and the S3 locked and reloaded, the files still being there.
No matter what is in the directory, my S3 always reloads.
Do you need more info about my S3, settings or anything?

Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #67 on: 01 / April / 2008, 06:46:39 »
I have an A570IS.  This is a superb feature and I now use it constantly.  I would like to echo obitus' comments above.. but it's weird...

First tried it all options/levels to try it worked, and the easiest was to highlight DCIM folder and purge all.  However, after a day of doing this, it stopped working.  Now as described by obitus, when I try it, the camera locks up (screen image is updated with what the lens sees, but no menu/buttons work.  After couple of seconds the camera goes blank, with lens out if out etc.  A power up restores camera, but the RAW's are still there.

It seems to work if I do the procedure on the 100CANON folder (or whatever the last folder is called before the images).  But it is annoying that it did work and now it's locking the camera up.

Does the code log all images deleted or have a limited buffer or something?  It seems weird it worked perfect for a set amount of time - i'd say I deleted 30-50 before it stopped working, but that is a rough guess if it helps!

Steveo
PS 570IS User
EOS 350D/XT User


*

Offline wontolla

  • ****
  • 413
  • S3 & G9 & A720
Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #68 on: 01 / April / 2008, 08:13:16 »
Thanks guys for your input.

I made several tests last night. Given the weird behaviour I thought the problem was when the folder had too many files and the memory of the camera couldn't cope with it. So I tested with 200 photos and erasing 100 random JPG files. And it worked like a charm! It took like one minute but no hanging.
But then I did the same 200 photos but erasing only one JPG and the camera frizzed.

I will try to change the searching method (may be several partial searches instead of one big loop), I still think there is a problem with the camera's memory but unfortunately I don't understand how things work at low level so may be another developer has a clue. May be there is a way to know state of the memory, if it is full etc.

I'll let you know when I have a new build.
Any clues developers?

This is the Purge RAW function code, three main parts:
1.- is executed when erasing everything in DCIM folder
2.- is executed when a Canon folder is selected
3.- is executed when you call the function in the file list


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

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

    if (btn==MBOX_BTN_YES) {
        //If selected folder is DCIM (this is to purge all RAW files in any Canon folder)
        if (selected->name[0] == 'D' && selected->name[1] == 'C' && selected->name[2] == 'I' && selected->name[3] == 'M') {
            sprintf(current_dir+strlen(current_dir), "/%s", selected->name);
            d=opendir(current_dir);
            while ((de=readdir(d)) != NULL) {//Loop to find all Canon folders
                if (de->name[0] != '.' && de->name[1] != '.') {//If item is not UpDir
                    sprintf(sub_dir, "%s/%s", current_dir, de->name);
                    d2=opendir(sub_dir);
                    while ((de2=readdir(d2)) != NULL) {//Loop to find all the RAW files inside a Canon folder
                        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) {//Loop to find all Canon folders
                                if (de3->name[0] != '.' && de3->name[1] != '.') {//If item is not UpDir
                                    sprintf(sub_dir_search, "%s/%s", current_dir, de3->name);
                                    d4=opendir(sub_dir_search);
                                    while ((de4=readdir(d4)) != NULL) {//Loop to find a corresponding JPG file inside a Canon folder
                                        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)) {//If file is JPG, is not CRW/CR2 and is not a deleted item
                                            started();
                                            found=1;//A JPG file with the same Canon number was found
                                        }                                 
                                    }
                                    closedir(d4);                 
                                } 
                            }
                            closedir(d3);
                            //If no JPG found, delete RAW file
                            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;
        }
        //If item is a Canon folder (this is to purge all RAW files inside a single Canon folder)
        else if (selected->name[3] == 'C') {
            sprintf(current_dir+strlen(current_dir), "/%s", selected->name);
            d=opendir(current_dir);
            while ((de=readdir(d)) != NULL) {//Loop to find all the RAW files inside the Canon folder
                if (de->name[0] == 'C' || de->name[9] == 'C') {//If file is RAW (Either CRW/CR2 prefix or file extension)
                    d2=opendir(current_dir);
                    while ((de2=readdir(d2)) != NULL) {//Loop to find a corresponding JPG file inside the Canon folder
                        if (de->name[4] == de2->name[4] && de->name[5] == de2->name[5] &&//If the four digits of the Canon number are the same
                            de->name[6] == de2->name[6] && de->name[7] == de2->name[7] &&
                            de2->name[9] == 'J' && !(de2->name[0] == 'C' || de2->name[9] == 'C' || de2->name[0] == 0xE5)) {//If file is JPG and is not CRW/CR2 and is not a deleted item
                            started();
                            found=1;//A JPG file with the same Canon number was found
                        }                                 
                    }
                    closedir(d2);
                    //If no JPG found, delete RAW file               
                    if (found == 0) {
                        sprintf(selected_item, "%s/%s", current_dir, de->name);
                        remove(selected_item);
                        finished();
                    }
                    else {
                        found=0;
                        finished();
                    }
                }
            }
            closedir(d);
            i=strlen(current_dir);
            while (current_dir[--i] != '/');
            current_dir[i]=0;
        }
        else {
            //If inside a Canon folder (files list)
            for (ptr=head; ptr; ptr=ptr->next) {//Loop to find all the RAW files in the list
                if ((ptr->name[0] == 'C' || ptr->name[9] == 'C') && !(ptr->marked)) {//If file is RAW (Either CRW/CR2 prefix or file extension) and is not marked
                    for (ptr2=head; ptr2; ptr2=ptr2->next) {//Loop to find a corresponding JPG file in the list
                        if (ptr->name[4] == ptr2->name[4] && ptr->name[5] == ptr2->name[5] &&//If the four digits of the Canon number are the same
                            ptr->name[6] == ptr2->name[6] && ptr->name[7] == ptr2->name[7] &&
                            ptr2->name[9] == 'J' && !(ptr2->name[0] == 'C' || ptr2->name[9] == 'C')) {//If file is JPG and is not CRW/CR2
                            started();
                            found=1;
                        }
                    }
                    //If no JPG found, delete RAW file           
                    if (found == 0) {
                        sprintf(selected_file, "%s/%s", current_dir, ptr->name);
                        remove(selected_file);
                        finished();
                    }
                    else {
                        found=0;
                        finished();
                    }
                }
            }
        }
        gui_fselect_read_dir(current_dir);
    }
    gui_fselect_redraw = 2;
}

*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Erase JPG along with corresponding CRW in any folder - done
« Reply #69 on: 01 / April / 2008, 10:21:25 »
Just a minor speedup suggestion: to insert "break;" just after each "found=1;".

Code: (c) [Select]
                        sprintf(selected_file, "%s/%s", current_dir, ptr->name);I suspect here should be "selected_item", not "selected_file" ???

Code: (c) [Select]
                if (de->name[0] == 'C' || de->name[9] == 'C') {//If file is RAW (Either CRW/CR2 prefix or file extension)What about a deleted file with .CR* extension?

Code: (c) [Select]
                            de2->name[9] == 'J' && !(de2->name[0] == 'C' || de2->name[9] == 'C' || de2->name[0] == 0xE5)) {//If file is JPG and is not CRW/CR2 and is not a deleted itemMinor: Extra unnecessary check: "de2->name[9] == 'J'"  -> so it can'be "de2->name[9] == 'C'"
CHDK Developer.

 

Related Topics