From 3fdab4390396e48c13e4a8304f2d8688a1aea086 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Wed, 28 Dec 2022 15:36:48 +0100 Subject: [PATCH] Update cd-desktop.ps1, cd-downloads.ps1, and cd-music.ps1 --- Scripts/cd-desktop.ps1 | 12 ++++++------ Scripts/cd-downloads.ps1 | 12 ++++++------ Scripts/cd-music.ps1 | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Scripts/cd-desktop.ps1 b/Scripts/cd-desktop.ps1 index 1d691357..a66d94a3 100755 --- a/Scripts/cd-desktop.ps1 +++ b/Scripts/cd-desktop.ps1 @@ -14,16 +14,16 @@ try { if ($IsLinux) { - $Path = Resolve-Path "$HOME/Desktop" + $Path = Resolve-Path "~/Desktop" } else { $Path = [Environment]::GetFolderPath('DesktopDirectory') } - if (-not(Test-Path "$Path" -pathType container)) { - throw "Desktop folder at 📂$Path doesn't exist (yet)" + if (Test-Path "$Path" -pathType container) { + Set-Location "$Path" + "📂$Path" + exit 0 # success } - Set-Location "$Path" - "📂$Path" - exit 0 # success + throw "User's desktop folder at 📂$Path doesn't exist (yet)" } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" exit 1 diff --git a/Scripts/cd-downloads.ps1 b/Scripts/cd-downloads.ps1 index ff97e702..f5922521 100755 --- a/Scripts/cd-downloads.ps1 +++ b/Scripts/cd-downloads.ps1 @@ -14,16 +14,16 @@ try { if ($IsLinux) { - $Path = Resolve-Path "$HOME/Downloads" + $Path = Resolve-Path "~/Downloads" } else { $Path = (New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path } - if (-not(Test-Path "$Path" -pathType container)) { - throw "Downloads folder at 📂$Path doesn't exist (yet)" + if (Test-Path "$Path" -pathType container) { + Set-Location "$Path" + "📂$Path" + exit 0 # success } - Set-Location "$Path" - "📂$Path" - exit 0 # success + throw "User's downloads folder at 📂$Path doesn't exist (yet)" } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" exit 1 diff --git a/Scripts/cd-music.ps1 b/Scripts/cd-music.ps1 index 64e44a27..a565c9c0 100755 --- a/Scripts/cd-music.ps1 +++ b/Scripts/cd-music.ps1 @@ -14,16 +14,16 @@ try { if ($IsLinux) { - $Path = Resolve-Path "$HOME/Music" + $Path = Resolve-Path "~/Music" } else { $Path = [Environment]::GetFolderPath('MyMusic') } - if (-not(Test-Path "$Path" -pathType container)) { - throw "Music folder at 📂$Path doesn't exist (yet)" + if (Test-Path "$Path" -pathType container) { + Set-Location "$Path" + "📂$Path" + exit 0 # success } - Set-Location "$Path" - "📂$Path" - exit 0 # success + throw "User's music folder at 📂$Path doesn't exist (yet)" } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" exit 1