delete duplicate files with windows batch file?

Posted by Chris Sobolewski on Super User See other posts from Super User or by Chris Sobolewski
Published on 2011-09-12T01:19:21Z Indexed on 2012/11/03 17:08 UTC
Read the original article Hit count: 259

Filed under:
|
|
|

I have a program that automatically copies files to a directory, and if it creates a duplicate it will name it like so:

file with duplicate.xxx
file with duplicate - 1.xxx
file with duplicate - 2.xxx

I need a way to delete all the duplicates with a windows batch file.

Something along the lines of:

FOR %f IN (C:\files\*.*) DO del "%f - 1"

However, that will not work because that would resolve to file with duplicate - 1.xxx - 1

© Super User or respective owner

Related posts about Windows

Related posts about command-line