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
Answer
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.
No comments:
Post a Comment