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%"