From 19bcaa9e3ddf16569294c9ef42cf560a88487fd7 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Wed, 28 May 2025 17:45:23 +0200 Subject: [PATCH] Updated cd-music.ps1 --- scripts/cd-music.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/cd-music.ps1 b/scripts/cd-music.ps1 index 15241901..613cac3d 100755 --- a/scripts/cd-music.ps1 +++ b/scripts/cd-music.ps1 @@ -5,7 +5,7 @@ This PowerShell script changes the working directory to the user's music folder. .EXAMPLE PS> ./cd-music - 📂C:\Users\Markus\Music entered (has 0 files and 3 subfolders) + 📂C:\Users\Markus\Music entered (has 3 folders and 0 files) .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -14,17 +14,20 @@ try { if ($IsLinux) { + if (-not(Test-Path "~/Music/" -pathType container)) { + throw "No music folder at ~/Music/" + } $path = Resolve-Path "~/Music" } else { $path = [Environment]::GetFolderPath('MyMusic') - } - if (-not(Test-Path "$path" -pathType container)) { - throw "No music folder at 📂$path" + if (-not(Test-Path "$path" -pathType container)) { + throw "No music folder at: $path" + } } Set-Location "$path" $files = Get-ChildItem $path -attributes !Directory $folders = Get-ChildItem $path -attributes Directory - "📂$path entered (has $($files.Count) files and $($folders.Count) subfolders)" + "📂$path entered (has $($folders.Count) folders and $($files.Count) files)" exit 0 # success } catch { "⚠️ Error: $($Error[0])"