From ccdd85c14d9e1f16effef8e314849dc3c6051bec Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Mon, 9 Jan 2023 13:48:04 +0100 Subject: [PATCH] Update list-dir-tree.ps1 --- Scripts/list-dir-tree.ps1 | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Scripts/list-dir-tree.ps1 b/Scripts/list-dir-tree.ps1 index 740f51e7..26d3e727 100755 --- a/Scripts/list-dir-tree.ps1 +++ b/Scripts/list-dir-tree.ps1 @@ -15,22 +15,32 @@ 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 foreach($Item in $Items) { $Filename = $Item.Name - for ($i = 1; $i -lt $Depth; $i++) { Write-Host "│ " -noNewline } + 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