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