If you have a lot of images on your system, you know that managing the files and structure can be challenging and time consuming.
For example, new tools can make old workflow practices obsolete. For instance, PM 4.6 has the ability to save (optionally with crop) downsized jpgs directly from a raw file. To do so previously, one had to have a jpg of the raw file. As a result you may now have a lot of unnecessary jpg files on your system. To purge these files, you can use the following batch file which I call delmatchingjpg.bat.
Usual disclaimers: Use at your own risk. No warranty whatsoever!!
The batch file looks for nef+jpg pairs and if it finds a pair, it will just list or display the jpg filename. To actually delete the matching jpg files, you must include the command line argument DELETE (not case sensitive).
To run the batch file, open a command window, go to the top directory you want to process, type "delmatchingjpg", and the batch file will process/traverse/recurse all subdirectories below the current directory and display the jpg filenamess which have a corresponding raw file.
To display help, type "delmatchingjpg /?".
The batch file does call CHOICE (a batch command) which was included in the command language, was taken out for a while, and now is back in I believe Windows 2003 and Vista. In short, if you get an error on the line containing CHOICE, you will have to install it from the Windows Resource Kit or download it from the web (search for choice.exe and install it in your Windows directory). XP users will have to do this.
To use it with Canon raw files, just change the _raw variable to CRW.
If you decide to try the batch file, I would strongly suggest doing so first against a backup copy of your data. I have only tested under Windows XP.
Tip: if you just type delmatchingjpg, all the matching jpg files will be displayed (but not deleted), but they will scroll by pretty quickly. You may want to try this variant:
delmatchingjpg > files.txt
This will send the output to files.txt and you can open this file in notepad to review all the matching files.
To actually delete the matching jpg files, type "delmatchingjpg DELETE" and you'll receive a prompt like:
Delete d:\photos\landscape\canyon_1234.jpg (Yes, No, Cancel, All)?
You can reply Yes, No, Cancel, or All. Only the first character is necessary.
If you reply All, the the batch files continues silently without displaying the files.
Comments, suggestions, and especially improvements are welcomed.
If you have a useful batch file you'd like to share, I would encourage you to do so.
IF NOT DEFINED _cmd SET _cmd=blank
IF %_cmd%==? GOTO :help
IF %_cmd%==/? GOTO :help
FOR /R %%G IN (*.jpg) DO CALL :process %%G
IF %_choice%==3 EXIT /B
IF NOT EXIST %_findname% EXIT /B
IF /I NOT "%_cmd%"=="DELETE" GOTO :report %1
IF NOT %_choice%==4 CALL :ask %1
IF %_choice%==2 EXIT /B
IF %_choice%==3 ECHO Cancelling, please wait ... && EXIT /B
CALL :sum %1
CHOICE /CYNCA /N Delete %1 (Yes, No, Cancel, All)?
CALL :sum %1
ECHO Found %1
SET /A _bytes+=%~z1/1000
SET /A _count+=1
IF %_bytes%==0 (ECHO No files processed) ELSE (ECHO %_count% matching files, %_bytes%KB)
ECHO delmatchingjpg [DELETE]
ECHO Batch file deletes all jpg files that have a corresponding nef file in the
ECHO same directory. To use a different raw file type, edit the _raw
ECHO variable in this batch file.
ECHO DELETE include this command to actually delete jpg files, otherwise just
ECHO list the files that have a corresponding nef file.
ECHO !! No warranty expressed or implied !!
ECHO !! Use at your own risk !!