LoginSignup
1
2

More than 5 years have passed since last update.

PowerShellメモ 特殊ディレクトリへ移動

Last updated at Posted at 2017-01-05

概要

カレントディレクトリを特殊ディレクトリに設定する関数。
プロファイルに登録しておくのがお勧め。

コード

<#
.SYNOPSIS
    デスクトップへ移動
#>
function CdDt
{
    Set-Location ([Environment]::GetFolderPath([Environment+SpecialFolder]::DesktopDirectory))
}

<#
.SYNOPSIS
    マイドキュメントへ移動
#>
function CdMd
{
    Set-Location ([Environment]::GetFolderPath([Environment+SpecialFolder]::MyDocuments))
}

<#
.SYNOPSIS
    マイピクチャへ移動
#>
function CdMp
{
    Set-Location ([Environment]::GetFolderPath([Environment+SpecialFolder]::MyPictures))
}

<#
.SYNOPSIS
    Program Filesへ移動
#>
function CdPf
{
    Set-Location ([Environment]::GetFolderPath([Environment+SpecialFolder]::ProgramFiles))
}

<#
.SYNOPSIS
    Program Files(x86)へ移動
#>
function CdPf86
{
    Set-Location ([Environment]::GetFolderPath([Environment+SpecialFolder]::ProgramFilesX86))
}

<#
.SYNOPSIS
    アプリケーションデータへ移動
#>
function CdAd
{
    Set-Location ([Environment]::GetFolderPath([Environment+SpecialFolder]::ApplicationData))
}
実行例
PS C:\Work> cdpf
PS C:\Program Files>

動作確認した環境

  • PowerShell V4 (Windows 8.1)
  • PowerShell V5 (Windows 10)

参考サイト

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2