Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Yes, I did see: Delete duplicate files with Windows batch file

But I was unable to modify it to check each subfolder of that I specify, I have:

del "c:\...\Pictures\*\*-001.*"

But it doesn't like it. I only need to go one folder deep (each subfolder is a month) and I don't need to check the Pictures\ root.

I've tried this:

FOR %%F IN ("C:\...\Pictures\") DO FOR %%f IN ("C:\...\Pictures\%%F\*-001.JPG") del "%%f"

But that still isn't correct. Can anyone lend me a hand? I've very limited experience in batch files.

share|improve this question
The question, as above, is how can I modify that line to delete duplicate files in every subfolder of `Pictures`, not just 'loose' files in that folder itself. – Ollie Ford Jul 3 '13 at 17:55
That now odd looking comment above was in response to someone asking "what is the question". – Ollie Ford Jul 5 '13 at 18:16
Why can't you just use windows search in Pictures to search for *001? Or del *-001.jpg /s – RJFalconer Aug 8 '14 at 16:02

Set your real %startfolder% and look at the output. If it is good, remove echo before del:

@echo off &SETLOCAL
SET "startfolder=."

FOR /r "%startfolder%" %%i IN (*) DO call:doit "%%~i"

SET "fname=%~nx1"
SET "fsize=!$%fname%!"
IF DEFINED $!fname! (
     IF "%fsize%"=="%~z1" ECHO DEL "%~1"
) ELSE (
     SET "$%~nx1=%~z1"

The code doesn't delete if filesizes are different.

share|improve this answer
Thanks for response - output not correct though. I don't fully understand your code, but nowhere does it look for -001 in the filename, it's those I want to remove. There's not many, they're just spread out, so I can forego a filesize check. Just delete anything ending -001.JPG. – Ollie Ford Jul 6 '13 at 14:56
You can change the code: FOR /r "%startfolder%" %%i IN (*-001.jpg) DO call:doit "%%~i" to get only JPG's. And sorry, this is my last visit here. The board told me for log in I have to disable my AdBlock. But I don't do that. You can put a new question at stackoverflow, if you want so. – Endoro Jul 6 '13 at 15:12
Still not correct. Thanks for the help - I just went through manually in Picasa. You spend that long on trying to script it.. you may as well just be manual about it! – Ollie Ford Jul 7 '13 at 0:21
@Endoro I have adblock enabled with most draconian settings and still can browse SU fine. Perhaps worthy of a question on meta – RJFalconer Aug 8 '14 at 16:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .