Yanor.net/
Wiki
Blog
GitHub
Sandbox
開始行:
* ファイル・フォルダの存在確認 Test-Path [#y7db7f89]
*** ファイルが存在するか? [#f4f471d5]
Test-Path .\1.txt -PathType Leaf
*** フォルダが存在するか? [#w307999c]
if (!(Test-Path .\dir1 -PathType Container)) {
echo "Not"
}
*** パスが存在するか? [#i6b38063]
$dir = Join-Path $env:USERPROFILE "Dropbox"
$file = 1.txt
$path = Join-Path $dir $file
if (Test-Path $path) {
echo "OK"
}
*** いずれか1つはファイルが存在するか? [#gb3284af]
$files = @("1.txt", "2.txt", "3.txt")
if (($files | % { Test-Path $_}) -contains $true) {
echo "Ok"
} else {
echo "Not"
}
** 参考 [#mf616e5d]
:Test-Path | https://technet.microsoft.com/en-us/library/...
:Using Test-Path to Verify the Existence of an Object | h...
終了行:
* ファイル・フォルダの存在確認 Test-Path [#y7db7f89]
*** ファイルが存在するか? [#f4f471d5]
Test-Path .\1.txt -PathType Leaf
*** フォルダが存在するか? [#w307999c]
if (!(Test-Path .\dir1 -PathType Container)) {
echo "Not"
}
*** パスが存在するか? [#i6b38063]
$dir = Join-Path $env:USERPROFILE "Dropbox"
$file = 1.txt
$path = Join-Path $dir $file
if (Test-Path $path) {
echo "OK"
}
*** いずれか1つはファイルが存在するか? [#gb3284af]
$files = @("1.txt", "2.txt", "3.txt")
if (($files | % { Test-Path $_}) -contains $true) {
echo "Ok"
} else {
echo "Not"
}
** 参考 [#mf616e5d]
:Test-Path | https://technet.microsoft.com/en-us/library/...
:Using Test-Path to Verify the Existence of an Object | h...
ページ名: