mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-19 08:52:05 +02:00
Updated some cd-*.ps1 scripts
This commit is contained in:
@@ -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
|
||||
📂C:\Users\Markus\Music entered (has 0 files and 3 folders)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@@ -18,12 +18,14 @@ try {
|
||||
} else {
|
||||
$path = [Environment]::GetFolderPath('MyMusic')
|
||||
}
|
||||
if (Test-Path "$path" -pathType container) {
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
if (-not(Test-Path "$path" -pathType container)) {
|
||||
throw "User's music folder at 📂$path doesn't exist (yet)"
|
||||
}
|
||||
throw "User's music folder at 📂$path doesn't exist (yet)"
|
||||
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)"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
|
Reference in New Issue
Block a user