Improved the scripts

This commit is contained in:
Markus Fleschutz 2021-02-10 18:54:31 +01:00
parent 61b0c3e65d
commit 47459e0139
3 changed files with 14 additions and 6 deletions

View File

@ -28,7 +28,7 @@ try {
}
$SymlinksTotal++
}
write-output "Done - found $SymlinksTotal symlinks total, $SymlinksBroken are broken"
write-host -foregroundColor green "Done - $SymlinksBroken out of $SymlinksTotal are broken"
exit $SymlinksBroken
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -12,9 +12,13 @@ try {
if ($DirTree -eq "" ) {
$DirTree = read-host "Enter the path to the directory tree"
}
write-progress "Listing empty subfolders in $DirTree ..."
(Get-ChildItem $DirTree -recurse | ? {$_.PSIsContainer -eq $True}) | ?{$_.GetFileSystemInfos().Count -eq 0} | select FullName
echo "Done."
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 {
write-output $_.FullName
$Count++
}
write-host -foregroundColor green "Done - found $Count empty directories"
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -13,8 +13,12 @@ try {
$DirTree = read-host "Enter the path to the directory tree"
}
write-progress "Listing empty files in $DirTree ..."
Get-ChildItem $DirTree -recurse | Where {$_.PSIsContainer -eq $false} | Where {$_.Length -eq 0} | select FullName
echo "Done."
[int]$Count = 0
Get-ChildItem $DirTree -recurse | Where {$_.PSIsContainer -eq $false} | Where {$_.Length -eq 0} | ForEach-Object {
write-output $_.FullName
$Count++
}
write-host -foregroundColor green "Done - found $Count empty files"
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"