mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-08 17:44:37 +02:00
Update list-dir-tree.ps1
This commit is contained in:
parent
4db1c30d76
commit
ccdd85c14d
@ -15,22 +15,32 @@
|
|||||||
|
|
||||||
param([string]$DirTree = "$PWD")
|
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)
|
function ListDir { param([string]$Directory, [int]$Depth)
|
||||||
$Depth++
|
$Depth++
|
||||||
$Items = Get-ChildItem -path $Directory
|
$Items = Get-ChildItem -path $Directory
|
||||||
foreach($Item in $Items) {
|
foreach($Item in $Items) {
|
||||||
$Filename = $Item.Name
|
$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*") {
|
if ($Item.Mode -like "d*") {
|
||||||
Write-Host "├─" -noNewline
|
Write-Host "├" -noNewline
|
||||||
Write-Host -foregroundColor green "📂$Filename"
|
Write-Host -foregroundColor green "📂$Filename"
|
||||||
ListDir "$Directory\$Filename" $Depth
|
ListDir "$Directory\$Filename" $Depth
|
||||||
$global:Dirs++
|
$global:Dirs++
|
||||||
} else {
|
} else {
|
||||||
if ($Filename -like "*.iso") { $Icon = "📀"
|
$Icon = GetFileIcon $Item.Extension
|
||||||
} elseif ($Filename -like "*.mp3") { $Icon = "🎵"
|
|
||||||
} elseif ($Filename -like "*.epub") { $Icon = "📓"
|
|
||||||
} else { $Icon = "📄" }
|
|
||||||
Write-Host "├$($Icon)$Filename ($($Item.Length) bytes)"
|
Write-Host "├$($Icon)$Filename ($($Item.Length) bytes)"
|
||||||
$global:Files++
|
$global:Files++
|
||||||
$global:Bytes += $Item.Length
|
$global:Bytes += $Item.Length
|
||||||
|
Loading…
Reference in New Issue
Block a user