mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-17 02:01:01 +01:00
Improve list-dir-tree.ps1
This commit is contained in:
parent
8fe002a867
commit
f43dc498e4
@ -19,22 +19,24 @@ function ListDir { param([string]$Directory, [int]$Depth)
|
|||||||
}
|
}
|
||||||
write-host -foregroundColor green "📂$Filename"
|
write-host -foregroundColor green "📂$Filename"
|
||||||
ListDir "$Directory\$Filename" $Depth
|
ListDir "$Directory\$Filename" $Depth
|
||||||
$global:NumDirs++
|
$global:Dirs++
|
||||||
} else {
|
} else {
|
||||||
for ($i = 1; $i -lt $Depth; $i++) {
|
for ($i = 1; $i -lt $Depth; $i++) {
|
||||||
write-host -nonewline "| "
|
write-host -nonewline "| "
|
||||||
}
|
}
|
||||||
write-host "|-$Filename ($($Item.Length) bytes)"
|
write-host "|-$Filename ($($Item.Length) bytes)"
|
||||||
$global:NumBytes += $Item.Length
|
$global:Files++
|
||||||
|
$global:Bytes += $Item.Length
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$global:NumDirs = 1
|
[int]$global:Dirs = 1
|
||||||
$global:NumBytes = 0
|
[int]$global:Files = 0
|
||||||
|
[int]$global:Bytes = 0
|
||||||
ListDir $DirTree 0
|
ListDir $DirTree 0
|
||||||
write-host "($($global:NumDirs) dirs, $($global:NumBytes) bytes total)"
|
write-host "($($global:Dirs) directories, $($global:Files) files, $($global:Bytes) bytes total)"
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user