DUPE.bat, duplicated hash finder

Off-topic posts of interest to the "Everything" community.
Post Reply
therube
Posts: 5696
Joined: Thu Sep 03, 2009 6:48 pm

DUPE.bat, duplicated hash finder

Post by therube »

DUPE.bat, duplicated hash finder (Everything version)

Code: Select all

:: DUPE.bat (chkdupE.bat) SjB 04/11/2026

:: search from command-line, for sha-1 duplicates; current directory; directory tree; anywhere
:: results are displayed in an Everything window/tab

:: if existing Everything window/tab Filter <> Everything, might be unexpected results... ?
:: might want, 	-filter Everything ?

:: prob should check for -e && [%2]==[]
:: similarly a -r at C:\ wouldn't be too good ;-)


SET EV=c:\dev\locate\15.1408\everything.exe -instance 1.5a


@if [%1]==[-r] goto recursive:
@if [%1]==[-e] goto everything:


:: gather (ONLY) (size &) sha-1 duplicated files
:: within the current directory (default)
:: %EV% -s*  parent:%cd%  dupe:size;sha1 sort:sha1 file: dupe-min:2  %*
%EV% -s*  parent:"%cd%"  dupe:size;sha1 file: dupe-min:2  %*
goto end:
:: aren't we guaranteed dupe:sha1, in which case... leave the  sort:sha1  out?


:: within the current directory tree
:recursive
:: %EV% -s*  %cd%  dupe:size;sha1 sort:sha1 file: dupe-min:2  %2 %3 %4 %5 %6 %7 %8 %9
%EV% -s*  "%cd%"  dupe:size;sha1 file: dupe-min:2  %2 %3 %4 %5 %6 %7 %8 %9
:: any reason to or not to use %cd%, vs., -path .  ?
goto end:

:: everywhere anywhere basically doing anything Everything can do.  command line args override
:: this .bat.  "errors"; redirects, invalid arguments..., may result in unexpected results :-)
:everything
@if [%2]==[] goto toobroad:
:: %EV% -no-match-path  -s*  dupe:size;sha1 sort:sha1 file: dupe-min:2  %2 %3 %4 %5 %6 %7 %8 %9
%EV% -no-match-path  -s*  dupe:size;sha1 file: dupe-min:2  %2 %3 %4 %5 %6 %7 %8 %9
goto end:


:: ugly way of getting rid of %1 from %*, case & shift is much nicer ;-)
:: allowing %* makes things more "dangerous"
:: %* terms are AND'd, you could OR, but that would be really really awkward, ugly (cause you'd need grouping & ESCaping)

:: depending on where this %2... are in relation to -s*, a search may or may not work...
:: chkdupe.bat regex:us{3,}
:: -s* %2 %3 %4 dupe:size;sha1 - does nothing
:: -s* dupe:size;sha1 %2 %3 %4 - WORKS
:: nope!  that was NOT it, the regex: needed QUOTES regex:"{3,}"
:: (or was it, "regex:(3,)" might work, depending on location of %2... ?
:: nonetheless, might be some other gotchas, like dupe-min:9 & /which/, :9 on the searchbar you change to change it to some other # ?


:toobroad
@echo Searching for Everything, but no filtering entered - toobroad, try again.
:nodups
@echo 0 duplicate size items, nothing more to do. bye.
@pause


:end

set your location to Everything.exe, as appropriate (& in "quotes", if needed)
set your -instance <name>, as appropriate (like 1.5a, for most)



05-26-26 updated, included quotes around, "%cd%"
therube
Posts: 5696
Joined: Thu Sep 03, 2009 6:48 pm

Re: DUPE.bat, duplicated hash finder

Post by therube »

current directory.
.
Everything - dupe.png
Everything - dupe.png (60.03 KiB) Viewed 2020 times
therube
Posts: 5696
Joined: Thu Sep 03, 2009 6:48 pm

Re: DUPE.bat, duplicated hash finder

Post by therube »

recursive.
.
Everything - dupe -r.png
Everything - dupe -r.png (59.53 KiB) Viewed 2017 times
therube
Posts: 5696
Joined: Thu Sep 03, 2009 6:48 pm

Re: DUPE.bat, duplicated hash finder

Post by therube »

everywhere.
.
Everything - dupe -e.png
Everything - dupe -e.png (37.4 KiB) Viewed 2017 times
Native2904
Posts: 111
Joined: Mon Nov 22, 2021 8:36 pm

Re: DUPE.bat, duplicated hash finder

Post by Native2904 »

Super awesome and extremely flexible… it basically replaces any duplicate file finder...

GRAZIE :mrgreen:
therube
Posts: 5696
Joined: Thu Sep 03, 2009 6:48 pm

Re: DUPE.bat, duplicated hash finder

Post by therube »

needs "QUOTES" on the PATH (if it contains <sp>) !!!

< %EV% -s* parent:%cd% dupe:size;sha1 sort:sha1 file: dupe-min:2 %*
> %EV% -s* parent:"%cd%" dupe:size;sha1 sort:sha1 file: dupe-min:2 %*

the reason it fails (may fail), is because parent: stops at the whitespace
- guess why? because the path is not in quotes ;-)

< %EV% -s* %cd% dupe:size;sha1 sort:sha1 file: dupe-min:2 %2 %3 %4 %5 %6 %7 %8 %9
> %EV% -s* "%cd%" dupe:size;sha1 sort:sha1 file: dupe-min:2 %2 %3 %4 %5 %6 %7 %8 %9

the reason the later, recursive search (-r) /may happen/ to work,
may happen to /somewhat/ work, is because... heh... i'm not really sure, heh,
but i suppose because of pure (dumb) luck ;-)

c:/out/1 2 3/
%cd% = c:/out/1 2 3, & that does get passed to Everything
& Everything searches for "c:/out/1" AND "2" AND "3", heh
isn't that sweet

man, i hate quotes. you can quote me on that.
& i've quoted myself on that - more then once.


(I've updated the first post, DUPE.bat.)
Post Reply