Delete files duplicated

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
btk
Posts: 13
Joined: 17 Apr 2014 21:51

Delete files duplicated

#1 Post by btk » 29 Nov 2017 11:39

Hello
and I'm not finding a way to delete duplicate files in the same folder. I have files that are with the following filename.

file.txt
file(2).txt

it is standard to have (2) in these duplicate files.
How do I delete using batch?

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Delete files duplicated

#2 Post by Squashman » 29 Nov 2017 11:46

Not bullet proof as this can also delete file named foo(bar).txt

Code: Select all

H:\deleteme>dir /a /b
file(2).txt
file(3).txt
file.txt
foobar(1).txt
foobar(2).txt
foobar.txt

H:\deleteme>del *(*).txt

H:\deleteme>dir /a /b
file.txt
foobar.txt

H:\deleteme>

Post Reply