diff --git a/Scripts/list-empty-dirs.ps1 b/Scripts/list-empty-dirs.ps1 index 06805deb..23d140a7 100755 --- a/Scripts/list-empty-dirs.ps1 +++ b/Scripts/list-empty-dirs.ps1 @@ -1,10 +1,10 @@ <# .SYNOPSIS - Lists empty subfolders within a directory tree + Lists empty subfolders .DESCRIPTION This PowerShell script scans and lists all empty subfolders within the given directory tree. .PARAMETER DirTree - Specifies the path to the directory tree + Specifies the path to the directory tree (current working directory by default) .EXAMPLE PS> ./list-empty-dirs C:\ .LINK @@ -16,16 +16,20 @@ param([string]$DirTree = "$PWD") try { - $DirTree = resolve-path "$DirTree/" - write-progress "Listing empty directories in $DirTree..." + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + $DirTree = Resolve-Path "$DirTree" + Write-Progress "Listing empty subfolders in $DirTree..." [int]$Count = 0 Get-ChildItem "$DirTree" -attributes Directory -recurse | Where {$_.GetFileSystemInfos().Count -eq 0} | ForEach-Object { - "📂 $($_.FullName)" + "📂$($_.FullName)" $Count++ } - "✔️ directory tree $DirTree has $Count empty directories" + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "✔️ found $Count empty subfolders within directory tree $DirTree in $Elapsed sec." exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" exit 1 -} +} \ No newline at end of file