From 89194a0286190ce3c31df9d9feb40f4b096b93c6 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Fri, 25 Feb 2022 13:20:48 +0100 Subject: [PATCH] Update cd-downloads.ps1 --- Scripts/cd-downloads.ps1 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Scripts/cd-downloads.ps1 b/Scripts/cd-downloads.ps1 index ae1b83c2..53568232 100755 --- a/Scripts/cd-downloads.ps1 +++ b/Scripts/cd-downloads.ps1 @@ -5,7 +5,7 @@ This PowerShell script changes the working directory to the user's downloads folder. .EXAMPLE PS> ./cd-downloads - 📂/home/Joe/Downloads + 📂C:\Users\Joe\Downloads .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -13,11 +13,15 @@ #> try { - $Path = resolve-path "$HOME/Downloads" - if (-not(test-path "$Path" -pathType container)) { + if ($IsLinux) { + $Path = Resolve-Path "$HOME/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)" } - set-location "$Path" + Set-Location "$Path" "📂$Path" exit 0 # success } catch {