mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-23 06:08:36 +01:00
Update list-dir-tree.ps1
This commit is contained in:
parent
4db1c30d76
commit
ccdd85c14d
@ -15,6 +15,19 @@
|
||||
|
||||
param([string]$DirTree = "$PWD")
|
||||
|
||||
function GetFileIcon { param([string]$Suffix)
|
||||
switch ($Suffix) {
|
||||
".csv" { return "📊" }
|
||||
".epub" { return "📓" }
|
||||
".gif" { return "🎨" }
|
||||
".iso" { return "📀" }
|
||||
".jpg" { return "🎨" }
|
||||
".mp3" { return "🎵" }
|
||||
".mkv" { return "🎬" }
|
||||
default { return "📄" }
|
||||
}
|
||||
}
|
||||
|
||||
function ListDir { param([string]$Directory, [int]$Depth)
|
||||
$Depth++
|
||||
$Items = Get-ChildItem -path $Directory
|
||||
@ -22,15 +35,12 @@ function ListDir { param([string]$Directory, [int]$Depth)
|
||||
$Filename = $Item.Name
|
||||
for ($i = 1; $i -lt $Depth; $i++) { Write-Host "│ " -noNewline }
|
||||
if ($Item.Mode -like "d*") {
|
||||
Write-Host "├─" -noNewline
|
||||
Write-Host "├" -noNewline
|
||||
Write-Host -foregroundColor green "📂$Filename"
|
||||
ListDir "$Directory\$Filename" $Depth
|
||||
$global:Dirs++
|
||||
} else {
|
||||
if ($Filename -like "*.iso") { $Icon = "📀"
|
||||
} elseif ($Filename -like "*.mp3") { $Icon = "🎵"
|
||||
} elseif ($Filename -like "*.epub") { $Icon = "📓"
|
||||
} else { $Icon = "📄" }
|
||||
$Icon = GetFileIcon $Item.Extension
|
||||
Write-Host "├$($Icon)$Filename ($($Item.Length) bytes)"
|
||||
$global:Files++
|
||||
$global:Bytes += $Item.Length
|
||||
|
Loading…
Reference in New Issue
Block a user