Duplicate file delete?

Soldato
Joined
7 May 2006
Posts
3,191
Location
Fort William
Hi, i have run a data recovery and somehow (doh) ended up with multiple copies of all the files.

All the files i wish to delete have a number in brackets after them (1), (2) etc.
Got literally 10k+ to delete.

Whats the best way to find them all and be able to delete them in one go?

Tried some software that found them but then wouldnt delete them for some reason :(

Cheers for reading :)
 
Are they all in the same directories or multiple directories?

Something in powershell might work for this. If they all contain "(<num>)" that could be used as a regular expression for the delete. Might be able to do it in a batch script as well. Will try make something if I get the chance this afternoon.
 
Can be done in 1 command in powershell. I have tested this and it works.

This code will list out all the files that will be deleted (note the '-whatif' parameter at the end of the line):

Code:
Get-ChildItem C:\ -recurse | Where-Object {$_.Name -match "\(\d\)"} | foreach ($_) {remove-item $_.fullname -whatif}

This code will delete the files:

Code:
Get-ChildItem C:\ -recurse | Where-Object {$_.Name -match "\(\d\)"} | foreach ($_) {remove-item $_.fullname}

If you need a different directory, replace the C:\ with where you want to start. If its 1 directory, remove the '-recurse' and edit the location.

To run, open a powershell command window and copy and paste the commands.
 
Windows 7 is quite smart just type ( in the search window (top right) and then CTRL + A, then hit Delete
 
Back
Top Bottom