Update open-downloads-folder.ps1

This commit is contained in:
Markus Fleschutz 2022-05-07 14:54:18 +02:00
parent 10f409d2c8
commit 537d2b245a

View File

@ -8,15 +8,19 @@
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
Author: Markus Fleschutz / License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
try { try {
$TargetDir = resolve-path "$HOME/Downloads" if ($IsLinux) {
if (-not(test-path "$TargetDir" -pathType container)) { $Path = Resolve-Path "$HOME/Downloads"
throw "Downloads folder at 📂$TargetDir doesn't exist (yet)" } else {
$Path = (New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path
} }
& "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" if (-not(Test-Path "$Path" -pathType container)) {
throw "Downloads folder at 📂$Path doesn't exist (yet)"
}
& "$PSScriptRoot/open-file-explorer.ps1" $Path
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"