Go-Music
Sets the working directory to the user's music folder
param([string]$path = "")
try {
if ($path -eq "") {
if ($IsLinux -or $IsMacOS) {
if (-not(Test-Path "~/Music/" -pathType container)) { throw "No 'Music' folder in your home directory (yet)" }
$path = Resolve-Path "~/Music"
} else {
$path = [Environment]::GetFolderPath('MyMusic')
if (-not(Test-Path "$path" -pathType container)) { throw "The path to music folder '$path' doesn't exist (yet)" }
}
}
Set-Location "$path"
$folders = Get-ChildItem $path -attributes Directory
$files = Get-ChildItem $path -attributes !Directory
"??$path entered (has $($folders.Count) folders and $($files.Count) files)"
exit 0 # success
} catch {
"?? ERROR: $($Error[0])"
exit 1
}