Improved the scripts by "-attributes"

This commit is contained in:
Markus Fleschutz 2021-02-27 11:43:38 +01:00
parent da8b23569c
commit a38160468e
2 changed files with 4 additions and 4 deletions

View File

@ -15,11 +15,11 @@ if ($DirTree -eq "" ) {
try {
write-progress "Listing empty directories in $DirTree..."
[int]$Count = 0
Get-ChildItem $DirTree -recurse | Where {$_.PSIsContainer -eq $true} | Where {$_.GetFileSystemInfos().Count -eq 0} | ForEach-Object {
Get-ChildItem $DirTree -attributes Directory -recurse | Where {$_.GetFileSystemInfos().Count -eq 0} | ForEach-Object {
write-output $_.FullName
$Count++
}
write-host -foregroundColor green "Done - found $Count empty directories"
write-host -foregroundColor green "OK - found $Count empty directories"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -15,11 +15,11 @@ if ($DirTree -eq "" ) {
try {
[int]$Count = 0
write-progress "Listing empty files in $DirTree ..."
get-childItem $DirTree -recurse | where {$_.PSIsContainer -eq $false} | where {$_.Length -eq 0} | foreach-object {
get-childItem $DirTree -attributes !Directory -recurse | where {$_.Length -eq 0} | foreach-object {
write-output $_.FullName
$Count++
}
write-host -foregroundColor green "Done - found $Count empty files"
write-host -foregroundColor green "OK - found $Count empty file(s)"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"