Rename to list-timezone.ps1

This commit is contained in:
Markus Fleschutz
2021-04-17 18:38:38 +02:00
parent 370fe6c7dc
commit 9aa997ebf5
6 changed files with 19 additions and 27 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/pwsh
#!/usr/bin/pwsh
<#
.SYNTAX list-empty-dirs.ps1 [<dir-tree>]
.DESCRIPTION lists empty subfolders within the given directory tree
@ -6,20 +6,17 @@
.NOTES Author: Markus Fleschutz / License: CC0
#>
param($DirTree = "")
if ($DirTree -eq "" ) {
$DirTree = read-host "Enter the path to the directory tree"
}
param($DirTree = "$PWD")
try {
$DirTree = resolve-path "$DirTree/"
write-progress "Listing empty directories in $DirTree..."
[int]$Count = 0
Get-ChildItem $DirTree -attributes Directory -recurse | Where {$_.GetFileSystemInfos().Count -eq 0} | ForEach-Object {
write-output $_.FullName
Get-ChildItem "$DirTree" -attributes Directory -recurse | Where {$_.GetFileSystemInfos().Count -eq 0} | ForEach-Object {
"📂 $($_.FullName)"
$Count++
}
write-host -foregroundColor green "OK - found $Count empty directories"
"✔️ directory tree $DirTree has $Count empty directories"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"