Skip to content

cd-videos

Sets the working directory to the user's videos folder

#requires -version 5.1

try {
	if ($IsLinux -or $IsMacOS) {
		if (-not(Test-Path "~/Videos" -pathType container)) { throw "No 'Videos' folder in your home directory (yet)" }
		$path = Resolve-Path "~/Videos"
	} else { 
		$path = [Environment]::GetFolderPath('MyVideos')
		if (-not(Test-Path "$path" -pathType container)) { throw "The path to video folder '$path' doesn't exist (yet)" }
	}
	Set-Location "$path"
	$files = Get-ChildItem $path -attributes !Directory
	$folders = Get-ChildItem $path -attributes Directory
	"📂$path with $($files.Count) files and $($folders.Count) folders entered."
	exit 0
} catch {
throw
}

This script has no configurable parameters.

An interactive directory of PowerShell scripts.