I have found a powershell function, which virtually does what I need, but not quite...
I want to find all child folders within a parent that ONLY have one file inside.
I have found some code which sucesfully finds all the correct children folders, now I'm not too sure how to do the move...
I've created a 'Foreach' loop, but not sure entirely how to move.... would Move-Item do it? Not sure
Please help
$RootFolder = "c:\myfolder"
$FoldersWithOnlyOneFile = Get-ChildItem $RootFolder -Recurse | `
Where {$_.PSIsContainer -and @( Get-ChildItem $_.Fullname | Where {!$_.PSIsContainer}).Length -eq 1 `
-and @( Get-ChildItem $_.Fullname | Where {$_.PSIsContainer}).Length -eq 0 }
Foreach($folder in $FoldersWithOnlyOneFile)
{
$Folder.FullName
Get-ChildItem $Folder.FullName
}