mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-10 18:58:21 +02:00
Improved the scripts by "-attributes"
This commit is contained in:
parent
da8b23569c
commit
a38160468e
@ -15,11 +15,11 @@ if ($DirTree -eq "" ) {
|
|||||||
try {
|
try {
|
||||||
write-progress "Listing empty directories in $DirTree..."
|
write-progress "Listing empty directories in $DirTree..."
|
||||||
[int]$Count = 0
|
[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
|
write-output $_.FullName
|
||||||
$Count++
|
$Count++
|
||||||
}
|
}
|
||||||
write-host -foregroundColor green "Done - found $Count empty directories"
|
write-host -foregroundColor green "OK - found $Count empty directories"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -15,11 +15,11 @@ if ($DirTree -eq "" ) {
|
|||||||
try {
|
try {
|
||||||
[int]$Count = 0
|
[int]$Count = 0
|
||||||
write-progress "Listing empty files in $DirTree ..."
|
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
|
write-output $_.FullName
|
||||||
$Count++
|
$Count++
|
||||||
}
|
}
|
||||||
write-host -foregroundColor green "Done - found $Count empty files"
|
write-host -foregroundColor green "OK - found $Count empty file(s)"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user