mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-26 06:18:17 +01:00
Improved the scripts by "-attributes"
This commit is contained in:
parent
da8b23569c
commit
a38160468e
@ -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])"
|
||||
|
@ -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])"
|
||||
|
Loading…
Reference in New Issue
Block a user