From 29a8c968f854e116a3538680f1eb39e10af4d787 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Thu, 29 May 2025 09:32:06 +0200 Subject: [PATCH] Updated some scripts --- scripts/cd-downloads.ps1 | 10 +++++----- scripts/cd-music.ps1 | 10 +++++----- scripts/cd-repos.ps1 | 10 ++++------ scripts/cd-scripts.ps1 | 8 +++----- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/scripts/cd-downloads.ps1 b/scripts/cd-downloads.ps1 index acdbc1c3..7259c6a0 100755 --- a/scripts/cd-downloads.ps1 +++ b/scripts/cd-downloads.ps1 @@ -4,8 +4,8 @@ .DESCRIPTION This PowerShell script changes the working directory to the user's downloads folder. .EXAMPLE - PS> ./cd-downloads - 📂C:\Users\Markus\Downloads entered (has 0 files and 0 folders) + PS> ./cd-downloads.ps1 + 📂C:\Users\Markus\Downloads with 0 files and 0 folders entered. .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -15,19 +15,19 @@ try { if ($IsLinux -or $IsMacOS) { if (-not(Test-Path "~/Downloads" -pathType container)) { - throw "No 📂Downloads folder in your home directory yet" + throw "No 'Downloads' folder in your home directory yet" } $path = Resolve-Path "~/Downloads" } else { $path = (New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path if (-not(Test-Path "$path" -pathType container)) { - throw "No downloads folder at 📂$path" + throw "No downloads 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) folders)" + "📂$path with $($files.Count) files and $($folders.Count) folders entered." exit 0 # success } catch { "⚠️ Error: $($Error[0])" diff --git a/scripts/cd-music.ps1 b/scripts/cd-music.ps1 index 613cac3d..78d5592c 100755 --- a/scripts/cd-music.ps1 +++ b/scripts/cd-music.ps1 @@ -4,8 +4,8 @@ .DESCRIPTION This PowerShell script changes the working directory to the user's music folder. .EXAMPLE - PS> ./cd-music - 📂C:\Users\Markus\Music entered (has 3 folders and 0 files) + PS> ./cd-music.ps1 + 📂C:\Users\Markus\Music with 3 folders and 0 files entered. .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -15,7 +15,7 @@ try { if ($IsLinux) { if (-not(Test-Path "~/Music/" -pathType container)) { - throw "No music folder at ~/Music/" + throw "No 'Music' folder in home directory" } $path = Resolve-Path "~/Music" } else { @@ -25,9 +25,9 @@ try { } } Set-Location "$path" - $files = Get-ChildItem $path -attributes !Directory $folders = Get-ChildItem $path -attributes Directory - "📂$path entered (has $($folders.Count) folders and $($files.Count) files)" + $files = Get-ChildItem $path -attributes !Directory + "📂$path with $($folders.Count) folders and $($files.Count) files entered." exit 0 # success } catch { "⚠️ Error: $($Error[0])" diff --git a/scripts/cd-repos.ps1 b/scripts/cd-repos.ps1 index b4b2c68a..f82e27ca 100755 --- a/scripts/cd-repos.ps1 +++ b/scripts/cd-repos.ps1 @@ -5,7 +5,7 @@ This PowerShell script changes the working directory to the folder for Git repositories. .EXAMPLE PS> ./cd-repos.ps1 - 📂C:\Repos (has 33 subfolders) + 📂C:\Repos with 33 folders entered. .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -23,13 +23,11 @@ try { } elseif (Test-Path "/repositories" -pathType container) { $path = "/repositories" } elseif (Test-Path "~/source/repos" -pathType container) { $path = "~/source/repos" # Visual Studio default } elseif (Test-Path "D:/Repos" -pathType container) { $path = "D:/Repos" # second HDD - } else { - throw "No folder found for Git repositories (in home or root directory) - Please create one." - } + } else { throw "Found no folder for Git repositories (in home or root directory) - Please create one." } $path = Resolve-Path $path Set-Location "$path" - $subfolders = Get-ChildItem $path -attributes Directory - "📂$path entered (has $($subfolders.Count) subfolders)" + $folders = Get-ChildItem $path -attributes Directory + "📂$path with $($folders.Count) folders entered." exit 0 # success } catch { "⚠️ Error: $($Error[0])" diff --git a/scripts/cd-scripts.ps1 b/scripts/cd-scripts.ps1 index c7fb9a27..1980fe5f 100755 --- a/scripts/cd-scripts.ps1 +++ b/scripts/cd-scripts.ps1 @@ -5,7 +5,7 @@ This PowerShell script changes the working directory to the PowerShell scripts folder. .EXAMPLE PS> ./cd-scripts.ps1 - 📂C:\Repos\PowerShell\scripts entered (has 645 scripts) + 📂C:\Repos\PowerShell\scripts with 655 scripts entered. .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -14,12 +14,10 @@ try { $path = Resolve-Path "$PSScriptRoot" - if (-not(Test-Path "$path" -pathType container)) { - throw "No PowerShell scripts folder at 📂$path" - } + if (-not(Test-Path "$path" -pathType container)) { throw "No scripts folder at: $path" } Set-Location "$path" $files = Get-ChildItem $path -attributes !Directory - "📂$path entered (has $($files.Count) scripts)" + "📂$path with $($files.Count) scripts entered." exit 0 # success } catch { "⚠️ Error: $($Error[0])"