Directory Navigation
directory-navigation.ps1 · Download Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | # Directory Navigation Functions # Collection of functions for quickly navigating to common directories function ChDir-Work { param ( [string]$workPath = "<path/to/work/folder>" ) Write-Host "--------------------------------------------------------" Write-Host "Changing directory to Work folder: $workPath" if (Test-Path $workPath) { Set-Location -Path $workPath Write-Host "Changed directory to '$workPath'." } else { Write-Host "Directory '$workPath' does not exist." } Write-Host "--------------------------------------------------------" } function ChDir-Documents { param ( [string]$docPath = "$env:USERPROFILE\Documents" ) Write-Host "--------------------------------------------------------" Write-Host "Changing directory to Documents folder: $docPath" if (Test-Path $docPath) { Set-Location -Path $docPath Write-Host "Changed directory to '$docPath'." } else { Write-Host "Directory '$docPath' does not exist." } Write-Host "--------------------------------------------------------" } function ChDir-Downloads { param ( [string]$docPath = "$env:USERPROFILE\Downloads" ) Write-Host "--------------------------------------------------------" Write-Host "Changing directory to Downloads folder: $docPath" if (Test-Path $docPath) { Set-Location -Path $docPath Write-Host "Changed directory to '$docPath'." } else { Write-Host "Directory '$docPath' does not exist." } Write-Host "--------------------------------------------------------" } function ChDir-CustomProject { <# .SYNOPSIS Navigate to a custom project directory .DESCRIPTION Template function for navigating to project directories .PARAMETER projectPath The path to the project directory .EXAMPLE ChDir-CustomProject -projectPath "C:\Projects\MyProject" #> param ( [string]$projectPath = "<path/to/project/folder>" ) Write-Host "--------------------------------------------------------" Write-Host "Changing directory to project folder: $projectPath" if (Test-Path $projectPath) { Set-Location -Path $projectPath Write-Host "Changed directory to '$projectPath'." } else { Write-Host "Directory '$projectPath' does not exist." } Write-Host "--------------------------------------------------------" } # Export functions Export-ModuleMember -Function ChDir-Work, ChDir-Documents, ChDir-Downloads, ChDir-CustomProject |