Improve list-formatted.ps1

This commit is contained in:
Markus Fleschutz 2021-04-18 17:29:25 +02:00
parent f83042c654
commit 8e1a552dc2

View File

@ -11,12 +11,14 @@ param($Directory = "$PWD")
function ListDir { param([string]$Path) function ListDir { param([string]$Path)
$Items = get-childItem -path $Path $Items = get-childItem -path $Path
foreach ($Item in $Items) { foreach ($Item in $Items) {
if ($Item.Name[0] -eq '.') { continue } # hidden file/dir $Name = $Item.Name
if ($Item.Mode -like "d*") { if ($Name[0] -eq '.') { continue } # hidden file/dir
new-object PSObject -Property @{ Name = "📂$($Item.Name)" } if ($Item.Mode -like "d*") { $Icon = "📂"
} else { } elseif ($Name -like "*.iso") { $Icon = "📀"
new-object PSObject -Property @{ Name = "📄$($Item.Name)" } } elseif ($Name -like "*.mp3") { $Icon = "🎵"
} } elseif ($Name -like "*.epub") { $Icon = "📓"
} else { $Icon = "📄" }
new-object PSObject -Property @{ Name = "$Icon$Name" }
} }
} }