How do I find and delete all files without a file extension and delete them?

Butler, Blake 20 Reputation points

I'm working with a recovery database that recovered data from a plex server. The data produced thousands of files with a GUID name without an extension. I want to just wipe all these files out and delete the subfolders.User's image

A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,035 questions
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 31,561 Reputation points

    Here's a script to start with.

    $path = "c:\temp\zzzz"
    $files = Get-ChildItem -Path $path -File -Recurse | Where-Object -Property Extension -eq ""
    "We found {0} files." -f $files.count
    $files | Remove-Item -whatif
    $dirs = Get-ChildItem -Path $path -Directory -Recurse | Sort-Object -Property Fullname -Descending   # process subfolders first
    foreach ($dir in $dirs) {
        $contents = Get-ChildItem $dir.FullName
        if ($contents.count -eq 0) {                  # delete empty folders 
            $dir | Remove-Item -WhatIf

0 additional answers

Sort by: Most helpful