Shardul Mote
Shardul Mote

Reputation: 1

How to view duplicate files in a drive using command in cmd

I want to view all the duplicate files present in a drive using command prompt. I have tried a few commands like tree but I am not satisfied by it.

Upvotes: 0

Views: 114

Answers (1)

dbenham
dbenham

Reputation: 130889

I'll assume you are simply looking for duplicate file names, regardless of content.

This is inherently a relatively slow process. If you want a script based solution, then your best bet is probably to write a custom powershell, VBScript, or JScript script.

But I have a pair of pure script based utilities that can give decent performance. You should still expect the command to take many minutes to begin printing results (perhaps hours? if a large drive). The entire directory listing must fit within 2 GBytes. This command will fail if the limit is exceeded.

This will not allow you to see files for which you do not have access.

jren "^.*" "name()+' : '+path()" /list /j /s /p c:\ | sort | jrepl "^(.*? : ).*\n(?:\1.*\n)+" "$0" /m /i /jmatch

The above works by first using JREN to recursively list all files, one file per line as

fileName : fullFilePath

The list is then sorted, and then JREPL is used to extract consecutive lines where the leading file name repeats.

JREN.BAT is available at http://www.dostips.com/forum/viewtopic.php?f=3&t=6081

JREPL.BAT is available at http://www.dostips.com/forum/viewtopic.php?f=3&t=6044

Use JREN /? and JREPL /? to get full documentation on the utilities.

Upvotes: 1

Related Questions