I have some files on my Hard Disk Drive that have no extensions whatsoever. It is very hard to find them manually, I really don't like the fact that I would need to replace my mouse sooner because of the not vast, but yet very prominent damage, done to the hardware from trying to find those files by constantly clicking and scrolling, since they are a few hundred files out of thousands in a single folder.

Does anyone here know of a cmd or PowerShell command, or some Windows Explorer search advanced query syntax to help simplify this task?

  • What is the question?
    – Toto
    Apr 9 '18 at 9:29
  • are you joking with that Lorem Ipsum text?
    – SimonS
    Apr 9 '18 at 11:32
  • 1
    Explorer: kind:= -folder extension:= "".
    – user364455
    Apr 9 '18 at 16:16
  • @PetSerAl doesn't seem to be working unfortunately(also tried tweaking it, swapping them around but nothing). Apr 9 '18 at 18:38
  • 1
    @computationalprince It seems to work only in indexed locations. This should work in not indexed locations too: kind:= -folder type:= -[] extension:= [].
    – user364455
    Apr 9 '18 at 19:28

Finding Files with No File Extensions with Windows

Windows Explorer - Advanced Query Syntax

As per PetSerAl here are some of the File Explorer Advanced Query Syntax method to start with but read further down for the equivalent Command Line and Batch Script methods for this task.

Recursive Search

kind:= -folder type:= -[] extension:= []


Just select the "Current Folder" option thru the GUI "Search" tab

enter image description here


kind:= -folder type:= -[] extension:= [] folder:"C:\folder\path"

You can use a for /f loop iterating the output of a dir command with the /B and /A-D parameters, and then use some conditional if logic to only output files without any extensions using substitutions for the iterated files in the specified directory.

Command Line

Note: This assumes the directory you are in on the command line is the directory you are needing to search to display the files without extensions.

FOR /F "TOKENS=*" %A IN ('dir /B * /A-D') DO IF /I [%~nxA]==[%~nA] ECHO %~A

Batch Script

Note: This is a batch script that you set the SET Src= value to be the directory which you need to search to display files without extensions.

SET Src=C:\folder\path
FOR /F "TOKENS=*" %%A IN ('DIR /B "%Src%\*" /A-D') DO IF /I [%%~nxA]==[%%~nA] ECHO %%~A

Further Resources

  • For /F
  • FOR /?

    In addition, substitution of FOR variable references has been enhanced. You can now use the following optional syntax:

    %~nI        - expands %I to a file name only
    %~xI        - expands %I to a file extension only
  • Dir

  • If
  • From CMDs point of view, every file name containing a dot has an extension even if it's not one. So it might be worth checking the extension for validity by length or content. (assoc will list known extensions)
    – LotPings
    Apr 9 '18 at 14:11
  • 1
    It is quite easy to switch between recursive/non-recursive search thru GUI.
    – user364455
    Apr 11 '18 at 3:53
  • 1
    (1) The question does not specify a Windows version. Windows 7 and earlier do not have File Explorer; Windows Explorer (as explicitly cited by the OP) does not have a ribbon or anything similar to the “Search” tab you show. (2) FYI, I can confirm that the kind:= -folder type:= -[] extension:= [] Advanced Query Syntax works in Windows 7. But so does kind:-folder type:-[] extension:[] — you don’t need the = signs (or the spaces after them). In fact, kind:-folder extension:[] and type:-folder extension:[] seem to be good enough. … (Cont’d)
    – Scott
    Aug 24 '18 at 5:11
  • 1
    (Cont’d) …  (3) When does dir /B * /A-D produce a different result than dir /B /A-D (i.e., when does dir * produce a different result than dir)?
    – Scott
    Aug 24 '18 at 5:11

For the PowerShell solution:

Get-ChildItem -Path $Path -Recurse -File -Filter '*.'


Get-ChildItem -Path $Path -Recurse -File | Where-Object Extension -eq ''

Note that the -File parameter requires PowerShell v3+.


In Command Prompt, just use *.:

C:\directory\name> dir

08/24/2018  03:33 AM              .
08/24/2018  03:33 AM              ..
08/24/2018  03:33 AM                16 a
08/24/2018  03:33 AM                18 b.c
08/24/2018  03:33 AM                20 d.e.f
               3 File(s)             54 bytes

C:\directory\name> dir *.

08/24/2018  03:33 AM              .
08/24/2018  03:33 AM              ..
08/24/2018  03:33 AM                16 a
               1 File(s)             16 bytes


Remember, the Windows Command Prompt is not Unix.  In Unix filenames, dot (.) is just an ordinary character (except for the fact that filename that begin with dot are hidden).  In Unix, *e* means all filenames that contain an e, and *.* means all filenames that (explicitly) contain a ..

The rules for Command Prompt are trickier.  * means all filenames (even ones with an extension).  And *.* also means all filenames (even ones that do not contain a .).  But *. means all filenames that do not have an extension.

  • This also always matches the current and parent directory links of every directory you search in and that's not what you want when you search for files without an extension. Dec 9 '20 at 12:29
ls | ? {$_.Extension -eq ''}

This uses maximum shorthand. But it's the same code as @BaconBits really. I prefer shorthand. Its harder to read for beginner but more expressive and succinct

  • 2
    The reason why we have a minimum answer length is that we expect every post to have some level of explanation and / or commentary.
    – Scott
    Aug 24 '18 at 3:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.