diff --git a/Scripts/list-special-folders.ps1 b/Scripts/list-special-folders.ps1 index 97b65c87..70294437 100644 --- a/Scripts/list-special-folders.ps1 +++ b/Scripts/list-special-folders.ps1 @@ -2,7 +2,7 @@ .SYNOPSIS Lists special folders .DESCRIPTION - This PowerShell script lists the special folders (sorted alphabetically). + This PowerShell script lists all special folders (sorted alphabetically). .EXAMPLE PS> ./list-special-folders @@ -19,27 +19,33 @@ function GetTempDir { if ("$env:TEMP" -ne "") { return "$env:TEMP" } if ("$env:TMP" -ne "") { return "$env:TMP" } - if ($IsLinux) { return "/tmp" } + if ($IsLinux) { return "/tmp/" } return "C:\Temp" } function AddLine { param([string]$FolderName, [string]$FolderPath) - New-Object PSObject -property @{ 'Folder Name' = "$FolderName"; 'Folder Path' = "📂$FolderPath" } + if (Test-Path "$FolderPath" -pathType container) { + New-Object PSObject -property @{ 'Folder Name' = "$FolderName"; 'Folder Path' = "📂$FolderPath" } + } } function ListSpecialFolders { if ($IsLinux) { - AddLine "Desktop" "$HOME/Desktop" - AddLine "Downloads" "$HOME/Downloads" - AddLine "Home Folder" "$HOME" - AddLine "MyDocuments" "$HOME/Documents" - AddLine "MyMusic" "$HOME/Music" - AddLine "MyPictures" "$HOME/Pictures" - AddLine "MyScreenshots" "$HOME/Pictures/Screenshots" - AddLine "MyVideos" "$HOME/Videos" - AddLine "Temporary Folder" "$(GetTempDir)" + AddLine "Desktop" "$HOME/Desktop/" + AddLine "Documents" "$HOME/Documents/" + AddLine "Downloads" "$HOME/Downloads/" + AddLine "Dropbox" "$HOME/Dropbox/" + AddLine "Home" "$HOME/" + AddLine "Music" "$HOME/Music/" + AddLine "Pictures" "$HOME/Pictures/" + AddLine "Screenshots" "$HOME/Pictures/Screenshots/" + AddLine "Snap" "$HOME/snap/" + AddLine "Trash" "$HOME/.local/share/Trash/" + AddLine "Templates" "$Home/Templates/" + AddLine "Temporary" "$(GetTempDir)" $Path = Resolve-Path "$HOME/.." - AddLine "Users" "$Path" + AddLine "Users" "$Path/" + AddLine "Videos" "$HOME/Videos/" } else { $FolderNames = [System.Enum]::GetNames('System.Environment+SpecialFolder') $FolderNames | Sort-Object | ForEach-Object { @@ -54,9 +60,9 @@ function ListSpecialFolders { } try { - ListSpecialFolders | Format-Table -property @{e='Folder Name';width=22},'Folder Path' + ListSpecialFolders | Format-Table -property @{e='Folder Name';width=18},'Folder Path' exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" exit 1 -} \ No newline at end of file +}