Last edit: 11 / May / 2009I rewrote the code because the Purge RAW function was not working with some cameras.
This new version will:
Erase DNGs too.
Show before hand, the amount of memory to be claimed.
Warn you when there are no RAW/DNGs to be erased.
Due to my poor debugging skills, I deleted the function's capability of searching through several folders, which was the faulty bit. It was complex and un-useful in my opinion (I hope no-one misses this).
From now on, you will need to run the function from inside a Canon folder. Remember that you still can keep important RAW files from being wiped out by selecting them before purge.
Any comments/suggestions are welcomed.
The diff file is
here.I hope I can build and upload for people to test. The number of supported cameras has increased and it seems compilation time will be huge!
Have fun!
Last edit: 24 / April / 2008It works as follows:
The first step is to delete the JPG outtakes in playback mode (using Canon's interface).
Now you have 3 options to use Purge RAW function and erase the corresponding RAW files:
1.-
Delete all RAW files in DCIM folder including subfolders.Useful when:
You keep a separate folder for RAW files.
You set up the camera to create a new folder everyday (several days trek, holydays etc).
You want to erase the occasional mischievous RAW file stored in a different folder. Go to CHDK File Browser, select DCIM folder, push left button to display the popup menu and select "Purge RAW" (See photo 1). A warning will ask you to confirm (See photo 2) 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.
2.-
Delete all RAW files in a selected folder.Useful when:
You keep RAW files in the same folder as JPG files
You only want get rid of some RAW files. (Very important shots in some other folder).
You know which folder has a lot of outtakes.Go to CHDK File Browser and inside DCIM folder select the folder you want (E.g. "102CANON") and push the left button to display the popup menu. Select "Purge RAW". A warning will ask you to confirm and all the RAW files in ONLY that folder will be erased.
This option works like the previous one but only on the selected Canon folder, the rest are untouched.
3.-
Delete some or all RAW files in a list.Useful when:
You want to protect specific RAW files (to use them later for HDR)Go to CHDK File Browser, enter DCIM folder, enter a sub folder (E.g. "102CANON") push the left button to display the popup menu. Select "Purge RAW" (See photo 3). A warning will ask you to confirm and all the RAW files (See photo 4) will be gone.
Now the useful thing of this option is that you can mark the RAW files you DON'T want to erase (protect files). The Purge RAW function will erase the rest of the RAW files ignoring the marked ones.
Some
screenshots in replay #31
You can try it here but this is NOT an official build. The purpose should be testing the "Purge RAW" feature only. Do not use it with important shots. Remember, the only way for the community to get stable releases is to try/test these aditions BEFORE commiting. Erasing files in camera is an irreversible operation.
Links updated 24th April. Please report if it works in your camera or not. Any other link in this thread is outdated.
http://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a450-100d-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a460-100d-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a530-100a-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a540-100b-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a550-100c-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a560-100a-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a570-100e-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a570-101a-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a610-100e-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a610-100f-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a620-100f-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a630-100c-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a640-100b-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a650-100d-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a700-100b-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a710-100a-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-a720-100c-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-g7-100e-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-g7-100g-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-g7-100i-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-g7-100i-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus55_sd450-100b-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus55_sd450-100c-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus55_sd450-100d-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus65_sd630-100a-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus700_sd500-101a-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus700_sd500-101b-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus70_sd1000-100c-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus70_sd1000-101b-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus70_sd1000-102a-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus800_sd700-100b-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus800_sd700-101b-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus850_sd800-100e-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus860_sd870-100c-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-ixus950_sd850-100c-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-s2is-100e-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-s2is-100f-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-s2is-100g-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-s3is-100a-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-s5is-101a-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-s5is-101b-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-tx1-100g-50.ziphttp://wontolla.freeweb7.com/CHDK/PurgeRAW/allbest-tx1-101b-50.zipAny comments/suggestions will be appreciated.
I'm not writing the C code in this post, it is too long. If you want to see it here is the diff file. It is getting complicated so I started adding comments.
purgeraw.diff - 0.01MBCheers!
Since I started using CHDK for RAW pictures, my 2Gb SD cards feel like 512Mb ones. I use to erase outtake pictures in the field to reclaim some space and also to save time when choosing keepers back home. But for it to be worth, the CRW must be erased too.
I've been studying the CHDK code and I manage to erase the CRW automatically when erasing the JPG in the file browser (small addition to the fselect_delete_file_cb() function). But it would be much easier for the user to be looking at the picture instead the file name.
I think it would be nice when in playback mode, when pressing the "erase" button the CRW goes bye bye too, but I don't know how to sense keys when in playback mode. Any suggestions?
Other way is to first erase all the JPGs you want and then in the file browser, hit the left-key menu and select some kind of "erase crw of missing jpgs", but for that I need a SEARCH function or two nested "while" loops to search for every CRW file if it exist the corresponding JPG (with the file number).
I hope the experienced guys with the CHDK C code can give some hints or suggestions on this.
In few words:
How to react to the "erase" button when in playback mode?
If this is not possible, how to search for a file name in the directory?
For the first approach, it is only to add this lines in the appropriate place:
selected_file[16]='C';
selected_file[17]='R';
selected_file[18]='W';
selected_file[25]='C';
selected_file[26]='R';
selected_file[27]='W';
remove(selected_file);
For the second approach, I want to create a new function similar to fselect_delete_folder_cb(), for example
while (de) {
if (de->name[0] != 0xE5 /* deleted entry */ && (de->name[0]!='.' || (de->name[1]!='.' && de->name[1]!=0) || (de->name[1]=='.' && de->name[2]!=0))) {
started();
sprintf(selected_file, "%s/%s", current_dir, de->name);
remove(selected_file);
finished();
}
de = readdir(d);
}
closedir(d);
I want to modify this part to detect if the file is a CRW
if (de->name[0]=='C'...
Then to start a search in the directory looking for the JPG file with the same number assigned by the camera
if (canon_number[0]==de->name[4] && canon_number[1]==de->name[5] && canon_number[2]==de->name[6] && canon_number[3]==de->name[7])
If not found, erase the CRW file and do the same with the next CRW file until all of them are searched.
Thank you in advance guys and have fun!