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)
$Items = get-childItem -path $Path
foreach ($Item in $Items) {
if ($Item.Name[0] -eq '.') { continue } # hidden file/dir
if ($Item.Mode -like "d*") {
new-object PSObject -Property @{ Name = "📂$($Item.Name)" }
} else {
new-object PSObject -Property @{ Name = "📄$($Item.Name)" }
}
$Name = $Item.Name
if ($Name[0] -eq '.') { continue } # hidden file/dir
if ($Item.Mode -like "d*") { $Icon = "📂"
} elseif ($Name -like "*.iso") { $Icon = "📀"
} elseif ($Name -like "*.mp3") { $Icon = "🎵"
} elseif ($Name -like "*.epub") { $Icon = "📓"
} else { $Icon = "📄" }
new-object PSObject -Property @{ Name = "$Icon$Name" }
}
}