Find duplicate file names with different extension

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
Mufasa
Posts: 7
Joined: Wed Dec 30, 2020 4:39 pm

Find duplicate file names with different extension

Post by Mufasa »

Hey guys, a noob here.
I am trying to search for files that have a duplicate in the same directory with a different extension.
example
C:\users\user1\Downloads\file1.exe
C:\users\user1\Downloads\file1.exe.old

Ideally I'm only interested to see the file1.exe.old

Would appreciate anyone's help
NotNull
Posts: 5167
Joined: Wed May 24, 2017 9:22 pm

Re: Find duplicate file names with different extension

Post by NotNull »

Does this thread help you?
Mufasa
Posts: 7
Joined: Wed Dec 30, 2020 4:39 pm

Re: Find duplicate file names with different extension

Post by Mufasa »

NotNull wrote: Wed Dec 30, 2020 5:27 pm Does this thread help you?
Not exactly.
Basically I want to delete any files that have .exe.old as long there's version of it that matches the name without .old

I saw the following but I couldn't get it to work
void wrote: Tue Jan 28, 2020 10:46 am It's implemented for the next major version. No release date yet sorry.

Basic syntax will be:
path:regex:^(.*)\.mp3 fileexists:\1.jpg
-matches mp3 files that have a jpg file with the same stem.

The fileexists: search function must take a full path and filename as a parameter. \1 - \9 can be used to substitute regex matches.
path:regex: will force the regular expression to capture the entire path.
NotNull
Posts: 5167
Joined: Wed May 24, 2017 9:22 pm

Re: Find duplicate file names with different extension

Post by NotNull »

That is hard to accomplish with Everything. Basically you want to search for type 1 files and want it to find type 2 ...

But wth a little script that is much easier:
  • Save the code from Del_ExeOld.cmd somewhere on your disk
  • In Everything, search for
    ext:exe.old
  • Menu:File > Export
  • Save as type = Text Files (*.txt)
  • File Name = delold.txt
  • Save it in the same folder where Del_ExeOld.cmd is.
  • In File Explorer, browse to this folder
  • Double-click Del_ExeOld.cmd. This will start a simulation. No files will be deleted
  • Check the output. It will be similar to this:
    "T:\folder\some.exe.old" will be deleted as ""T:\folder\some.exe" exists

If output looks OK to you, change the code to actiually delete the files:
  • Edit Del_ExeOld.cmd so that it looks like this:

    Code: Select all

    @echo off
    
    for /f "delims=" %%X in (delold.lst) do if exist "%%~dpnX" del "%%~fX"
    
    pause
    
  • Run teh script
  • Done

Del_ExeOld.cmd

Code: Select all

@echo off

for /f "delims=" %%X in (delold.lst) do if exist "%%~dpnX" echo "%%~fX" will be deleted as "%%~dpnX" exists

REM for /f "delims=" %%X in (delold.lst) do if exist "%%~dpnX" del "%%~fX"

pause
NotNull
Posts: 5167
Joined: Wed May 24, 2017 9:22 pm

Re: Find duplicate file names with different extension

Post by NotNull »

Mufasa wrote: Wed Dec 30, 2020 5:51 pm I saw the following but I couldn't get it to work
That will be implemented in Everything 1.5, thenext major version.
That version is currently in development, but will take a while before release (check the to do list ...)

So: no release date of version 1.5 known at the moment.
Mufasa
Posts: 7
Joined: Wed Dec 30, 2020 4:39 pm

Re: Find duplicate file names with different extension

Post by Mufasa »

NotNull wrote: Wed Dec 30, 2020 7:41 pm That is hard to accomplish with Everything. Basically you want to search for type 1 files and want it to find type 2 ...

But wth a little script that is much easier:
  • Save the code from Del_ExeOld.cmd somewhere on your disk
  • In Everything, search for
    ext:exe.old
  • Menu:File > Export
  • Save as type = Text Files (*.txt)
  • File Name = delold.txt
  • Save it in the same folder where Del_ExeOld.cmd is.
  • In File Explorer, browse to this folder
  • Double-click Del_ExeOld.cmd. This will start a simulation. No files will be deleted
  • Check the output. It will be similar to this:
    "T:\folder\some.exe.old" will be deleted as ""T:\folder\some.exe" exists

If output looks OK to you, change the code to actiually delete the files:
  • Edit Del_ExeOld.cmd so that it looks like this:

    Code: Select all

    @echo off
    
    for /f "delims=" %%X in (delold.lst) do if exist "%%~dpnX" del "%%~fX"
    
    pause
    
  • Run teh script
  • Done

Del_ExeOld.cmd

Code: Select all

@echo off

for /f "delims=" %%X in (delold.lst) do if exist "%%~dpnX" echo "%%~fX" will be deleted as "%%~dpnX" exists

REM for /f "delims=" %%X in (delold.lst) do if exist "%%~dpnX" del "%%~fX"

pause
Sweet, I will give it a try.
Thanks!
Mufasa
Posts: 7
Joined: Wed Dec 30, 2020 4:39 pm

Re: Find duplicate file names with different extension

Post by Mufasa »

The above batch file works for most file but some files are ignored.
One example would be "file1.msg.old" and "file1.msg", the script doesn't seem to recognize the extension.
Any suggestion?
NotNull
Posts: 5167
Joined: Wed May 24, 2017 9:22 pm

Re: Find duplicate file names with different extension

Post by NotNull »

Mufasa wrote: Fri Jan 01, 2021 6:30 pm The above batch file works for most file but some files are ignored.
One example would be "file1.msg.old" and "file1.msg", the script doesn't seem to recognize the extension.
Any suggestion?
This is what you asked for:
Mufasa wrote: Wed Dec 30, 2020 5:51 pm Basically I want to delete any files that have .exe.old as long there's version of it that matches the name without .old
So that is what I wrote. The script checks for exe.old files.

Should it also check for .msg.old too or all .old files? Please be as specific as you can.
Mufasa
Posts: 7
Joined: Wed Dec 30, 2020 4:39 pm

Re: Find duplicate file names with different extension

Post by Mufasa »

NotNull wrote: Fri Jan 01, 2021 6:45 pm
Mufasa wrote: Fri Jan 01, 2021 6:30 pm The above batch file works for most file but some files are ignored.
One example would be "file1.msg.old" and "file1.msg", the script doesn't seem to recognize the extension.
Any suggestion?
This is what you asked for:
Mufasa wrote: Wed Dec 30, 2020 5:51 pm Basically I want to delete any files that have .exe.old as long there's version of it that matches the name without .old
So that is what I wrote. The script checks for exe.old files.

Should it also check for .msg.old too or all .old files? Please be as specific as you can.
I did modify the search to look for other extensions and it work but not for all files.
I doubt the issue is the script, maybe permission issues on those files.

Using the same script, can it compare file sizes and only delete file.exe.old if it matches file.exe.old in name and size?

Thanks for your help!
NotNull
Posts: 5167
Joined: Wed May 24, 2017 9:22 pm

Re: Find duplicate file names with different extension

Post by NotNull »

Mufasa wrote: Sat Jan 02, 2021 11:49 pm Using the same script, can it compare file sizes and only delete file.exe.old if it matches file.exe.old in name and size?
Yes, sure. As I don't have much time to test it at this moment, just a simulation version. Let me know if it works as expected so I can write an execute version.

Code: Select all

for /f "delims=" %%X in (exeold.lst) do if exist "%%~dpnX" for %%Y in ("%%~dpnX") do if %%~zY == %%~zX echo "%%~fX" will be deleted as "%%~dpnX" exists and has same size %%~zX
Post Reply