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?
4 Answers
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:= []Non-Recursive
Just select the "Current Folder" option thru the GUI "Search" tab
or
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 %~ABatch 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.
@ECHO ON
SET Src=C:\folder\path
FOR /F "TOKENS=*" %%A IN ('DIR /B "%Src%\*" /A-D') DO IF /I [%%~nxA]==[%%~nA] ECHO %%~A
PAUSE
EXITFurther 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- If
For the PowerShell solution:
Get-ChildItem -Path $Path -Recurse -File -Filter '*.'Or:
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 C:\directory\name>
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.
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
1