PowerTip: Use PowerShell to Identify Files Without an Extension

Summary: Use Windows PowerShell to identify files that do not have an extension.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily identify files that do not have an extension?

Hey, Scripting Guy! Answer Use the HasExtension static method from the System.IO.Path .NET Framework class, for example:


Comments (3)

  1. GadgetHead says:

    More useful???

    dir test | ?{-not [System.IO.Path]::hasExtension($_)}

    I have 99 files with no extension. Where did they come from.

    Oh! (slaps head) – directories. Who would have guessed?

  2. Peter says:

    I read this as "file types" of files without an extension. That would be awesome to do in some accurate manner. Don’t have a call for it often, but it beats loading a file into some text/hex editor to try to glean some knowledge of the file within. 🙂

  3. Jon Wolthuis says:

    The title should read, "… to tell if a specific file has an extension." It doesn’t "identify", aka, sniff files without an extension, to identify spreadsheets versus documents. It simply returns True if the path ends with a dot plus one or more characters.

Skip to main content