From 47459e0139daf4edef6108416fec4848cb11712c Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Wed, 10 Feb 2021 18:54:31 +0100 Subject: [PATCH] Improved the scripts --- Scripts/check-symlinks.ps1 | 2 +- Scripts/list-empty-dirs.ps1 | 10 +++++++--- Scripts/list-empty-files.ps1 | 8 ++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Scripts/check-symlinks.ps1 b/Scripts/check-symlinks.ps1 index 0976c9c3..0bb874b9 100755 --- a/Scripts/check-symlinks.ps1 +++ b/Scripts/check-symlinks.ps1 @@ -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])" diff --git a/Scripts/list-empty-dirs.ps1 b/Scripts/list-empty-dirs.ps1 index 2b70fd3e..86cfa214 100755 --- a/Scripts/list-empty-dirs.ps1 +++ b/Scripts/list-empty-dirs.ps1 @@ -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])" diff --git a/Scripts/list-empty-files.ps1 b/Scripts/list-empty-files.ps1 index 0c0d8ddd..2d5a4004 100755 --- a/Scripts/list-empty-files.ps1 +++ b/Scripts/list-empty-files.ps1 @@ -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])"