How to search for files with the same name but different extensions

I am trying to use the following solution to search for files with the same name but different extensions in a directory:

Powershell -Command "& Get-ChildItem C:\Some_folder -Recurse -File | Group-Object -Property Directory,BaseName | Where-Object Count -gt 1 | Select-Object Name > C:\Temp\DoubleFilesName.txt"

For a small number of files it works, unfortunately in the case of, say, 12000 files in several subdirectories either takes a very long time or does not end.

Can this be improved?

Thank you in advance for your help

Helka,
Welcome to the forum. :wave:t4:

What do you mean with “takes a very long time”? I just checked it on my local computer on my slow HDD - not SSD - with a directory with more than 40,000 files in several subdirectories and it didn’t even take 6 seconds?! :man_shrugging:t4:

Hi Olaf
:running_man: On start-up, I have this screen:


After an :clock1: hour of waiting the result file 0 bytes

The folder is about 16,000 files and several subfolders.
With a few files, everything works quickly and correctly

I don’t understand what the problem is. :microscope:
I think I will write an application for this in C#

You may try to drop the code into an open console

Get-ChildItem -Recurse -File | 
    Group-Object -Property Directory,BaseName | 
        Where-Object Count -gt 1 | 
            Select-Object Name

Again … I tested it on a slow HDD with a folder with more than 40,000 files and it took 6 seconds (on PowerShell version 7). There might be an issue with your files

Is this a recurring task? At first you may switch to PowerShell version 7. That will already speed up this task.

Wow … really?

1 Like

Thank you very much!

From the console it worked.

Now how do I add this to the batch file to make it work?

If I think correctly the problem was the use of the: -Command & “”.

Thank you for your help.

What batch file? I’d recommend using a PowerShell script “*.ps1