diff --git a/README.md b/README.md index 0f33fd4..4897e44 100644 --- a/README.md +++ b/README.md @@ -75,17 +75,19 @@ lss -All ## πŸ“Έ Example Output ``` -Dizin: C:\Users\Muhammed +Directory: C:\Users\Muhammed ================================================================================ -TIP ISIM BOYUT +TYPE NAME SIZE ================================================================================ -πŸ“ KLS .cache 4.13 GB -πŸ“ KLS .local 5.66 GB -πŸ“ KLS .ollama 4.36 GB -πŸ“ KLS Apple 69.42 GB -πŸ“ KLS anaconda3 4.47 GB -πŸ“„ DSY install.ps1 21.57 KB -πŸ“„ DSY oracle-1 3.30 KB +πŸ“ DIR .cache 4.13 GB +πŸ“ DIR .local 5.66 GB +πŸ“ DIR .ollama 4.36 GB +πŸ“ DIR Apple 69.42 GB +πŸ“ DIR anaconda3 4.47 GB +πŸ“„ FILE install.ps1 21.57 KB +πŸ“„ FILE oracle-1 3.30 KB +================================================================================ +Ξ£ TOTAL 5 Folders, 2 Files 88.04 GB ================================================================================ ``` @@ -179,17 +181,19 @@ lss -All ## πŸ“Έ Γ–rnek Γ‡Δ±ktΔ± ``` -Dizin: C:\Users\Muhammed +Directory: C:\Users\Muhammed +================================================================================ +TYPE NAME SIZE ================================================================================ -TIP ISIM BOYUT +πŸ“ DIR .cache 4.13 GB +πŸ“ DIR .local 5.66 GB +πŸ“ DIR .ollama 4.36 GB +πŸ“ DIR Apple 69.42 GB +πŸ“ DIR anaconda3 4.47 GB +πŸ“„ FILE install.ps1 21.57 KB +πŸ“„ FILE oracle-1 3.30 KB ================================================================================ -πŸ“ KLS .cache 4.13 GB -πŸ“ KLS .local 5.66 GB -πŸ“ KLS .ollama 4.36 GB -πŸ“ KLS Apple 69.42 GB -πŸ“ KLS anaconda3 4.47 GB -πŸ“„ DSY install.ps1 21.57 KB -πŸ“„ DSY oracle-1 3.30 KB +Ξ£ TOTAL 5 Folders, 2 Files 88.04 GB ================================================================================ ``` diff --git a/lss.ps1 b/lss.ps1 index d7b4e5e..bc71bba 100644 --- a/lss.ps1 +++ b/lss.ps1 @@ -55,17 +55,18 @@ function Format-LssSize { param( [long]$Bytes ) + $culture = [System.Globalization.CultureInfo]::InvariantCulture if ($Bytes -ge 1GB) { - return "{0:N2} GB" -f ($Bytes / 1GB) + return "{0} GB" -f ($Bytes / 1GB).ToString("N2", $culture) } elseif ($Bytes -ge 1MB) { - return "{0:N2} MB" -f ($Bytes / 1MB) + return "{0} MB" -f ($Bytes / 1MB).ToString("N2", $culture) } elseif ($Bytes -ge 1KB) { - return "{0:N2} KB" -f ($Bytes / 1KB) + return "{0} KB" -f ($Bytes / 1KB).ToString("N2", $culture) } else { - return "{0} Bytes" -f $Bytes + return "{0} Bytes" -f $Bytes.ToString($culture) } } @@ -104,24 +105,36 @@ function lss { $resolvedPath = (Resolve-Path -Path $Path -ErrorAction SilentlyContinue).Path if (-not $resolvedPath) { $resolvedPath = $Path } - Write-Host "`nDizin: $resolvedPath" -ForegroundColor Cyan + Write-Host "`nDirectory: $resolvedPath" -ForegroundColor Cyan Write-Host ("="*80) -ForegroundColor Cyan - Write-Host ("{0,-8} {1,-50} {2,15}" -f "TIP", "ISIM", "BOYUT") -ForegroundColor Cyan + Write-Host ("{0,-8} {1,-50} {2,15}" -f "TYPE", "NAME", "SIZE") -ForegroundColor Cyan Write-Host ("="*80) -ForegroundColor Cyan + [int]$folderCount = 0 + [int]$fileCount = 0 + [long]$totalSize = 0 + foreach ($entry in $sorted) { $formattedSize = Format-LssSize -Bytes $entry.Size $displayName = $entry.Item.Name + $totalSize += $entry.Size + if ($displayName.Length -gt 48) { $displayName = $displayName.Substring(0, 45) + "..." } if ($entry.IsFolder) { - Write-Host ("{0,-8} {1,-50} {2,15}" -f "πŸ“ KLS", $displayName, $formattedSize) -ForegroundColor Yellow + $folderCount++ + Write-Host ("{0,-8} {1,-50} {2,15}" -f "πŸ“ DIR", $displayName, $formattedSize) -ForegroundColor Yellow } else { - Write-Host ("{0,-8} {1,-50} {2,15}" -f "πŸ“„ DSY", $displayName, $formattedSize) -ForegroundColor Green + $fileCount++ + Write-Host ("{0,-8} {1,-50} {2,15}" -f "πŸ“„ FILE", $displayName, $formattedSize) -ForegroundColor Green } } + + $formattedTotalSize = Format-LssSize -Bytes $totalSize + Write-Host ("="*80) -ForegroundColor Cyan + Write-Host ("{0,-8} {1,-50} {2,15}" -f "Ξ£ TOTAL", "$folderCount Folders, $fileCount Files", $formattedTotalSize) -ForegroundColor Cyan Write-Host ("="*80 + "`n") -ForegroundColor Cyan } \ No newline at end of file