Update cd-desktop.ps1, cd-downloads.ps1, and cd-music.ps1

This commit is contained in:
Markus Fleschutz 2022-12-28 15:36:48 +01:00
parent c8efe1f4ec
commit 3fdab43903
3 changed files with 18 additions and 18 deletions

View File

@ -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
}
throw "User's desktop folder at 📂$Path doesn't exist (yet)"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -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
}
throw "User's downloads folder at 📂$Path doesn't exist (yet)"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -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
}
throw "User's music folder at 📂$Path doesn't exist (yet)"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1