0

My backup software when it backups up a file share it injects a bunch of hidden folders with meta data about the files in every single folder and its children. There are hundreds of this folder name called .nt_streams.

I recently had to restore from backup and now all my files have this hidden directory everywhere. How can I use the CMD prompt to recursively scan through the entire folder hierarchy and remove this folder and the files inside of it?

I've looked around and can't find a consistent answer. Some people using for files, some using find, etc.

Here is an example of the structure:

Root Folder/
    .nt_steams/
    Folder1/
    Folder2/
        .nt_steams/
        Folder1
            .nt_streams/
                Folder1
                    .nt_streams/
                    File1
    Folder3/
        .nt_steams/
        File1
        File2
2

powershell

$folder = ".nt_streams"
$rootdir = "*root folder*"

$folders = gci $rootdir -recurse | where {$_.name -match $folder}

foreach($item in $folders){remove-item $item -force -whatif}

Remove the -whatif once you've run it once and confirmed that it is only targeting what you expect it to.

1
  • Worked, thanks. I did modify it slightly to be a one-liner though. Get-ChildItem "Z:\folder\path" -Force -Recurse | Where-Object {$_.name -eq ".nt_streams"} | Remove-Item -Force -Recurse Apr 24 '18 at 15:45

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.