Skip to content

cd-docs

Sets the working dir to the documents folder

#requires -version 5.1

try {
	if ($IsLinux -or $IsMacOS) {
		if (-not(Test-Path "~/Documents" -pathType container)) { throw "No 'Documents' folder in your home directory (yet)" }
		$path = Resolve-Path "~/Documents"
	} else {
		$path = [Environment]::GetFolderPath('MyDocuments')
		if (-not(Test-Path "$path" -pathType container)) { throw "The path to documents folder '$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
} catch {
throw
}

This script has no configurable parameters.

An interactive directory of PowerShell scripts.