mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-24 15:49:02 +01:00
Update list-empty-dirs.ps1
This commit is contained in:
parent
e85b6e594b
commit
b7f0bca5bb
@ -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,14 +16,18 @@
|
||||
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])"
|
||||
|
Loading…
Reference in New Issue
Block a user