Find duplicate file names with different extension
Find duplicate file names with different extension
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
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
Re: Find duplicate file names with different extension
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.
Re: Find duplicate file names with different extension
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:
If output looks OK to you, change the code to actiually delete the files:
Del_ExeOld.cmd
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
Re: Find duplicate file names with different extension
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.
Re: Find duplicate file names with different extension
Sweet, I will give it a try.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.cmdCode: 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
Thanks!
Re: Find duplicate file names with different extension
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?
One example would be "file1.msg.old" and "file1.msg", the script doesn't seem to recognize the extension.
Any suggestion?
Re: Find duplicate file names with different extension
This is what you asked for:
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.
Re: Find duplicate file names with different extension
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!
Re: Find duplicate file names with different extension
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