Hi guys, I have a problem needing solving and little batch coding experience.
Here is basically what I am trying to do:
for each file in subfolder "RAW"
IF NOT(.raw file has .jpg file one folder up that has the same name.)
delete current file
Description of situation:
This has to do with how I organize my DSLR pictures.
- When copying pictures from the camera I have a folder containing both .jpg and .raw of the same images.
- I then put the .raw files in a subfolder called RAW to separate the .jpg and .raw files.
- I then browse through the .jpg files and delete whatever pictures I don't need.
- The situation is now that I have the .jpg files I want to keep, but the RAW subfolder still contains all the original files.
- I want the RAW folder to only contain .raw files that has a .jpg file that has the same name one folder up in the file structure.
- Result should be that both folders contain the same amount of picture files, one folder with jpg and one with raw.
Any help on this "Clean up routine" would be greatly appreciated. Because the way it is now I have deleted alot of jpg files, but havent bothered to clean up the raw files. Since raw files take approx 4 times the harddisk space of a jpg my harddrive is now full and I really need to get this working so I can do a proper cleanup!
How to delete specific files?
Moderator: DosItHelp
Re: How to delete specific files?
Hello there Emi
I will try to help you with this script
So if i am correct, you have a folder filled with .jpg files and .raw files.
But you want the .jpg files in a sub-directory and the same with the .raw files in another one.
if this is all you need, then it's really easy to solve this
let me know

I will try to help you with this script

So if i am correct, you have a folder filled with .jpg files and .raw files.
But you want the .jpg files in a sub-directory and the same with the .raw files in another one.
if this is all you need, then it's really easy to solve this

let me know

Re: How to delete specific files?
This will echo onto the console the names of the .raw files that don't have a matching .jpg file in the parent folder.
Remove echo to enable the deletion after you test it.
Remove echo to enable the deletion after you test it.
Code: Select all
@echo off
cd /d "c:\pictures\raw"
for %%a in (*.raw) do if not exist "..\%%~na.jpg" echo del "%%a"