Skip to content

cd-music

Sets the working directory to the user's music folder

#requires -version 5.1

try {
	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
} catch {
throw
}

This script has no configurable parameters.

An interactive directory of PowerShell scripts.