如何使用powershell命令检查变量目录是否存在?

时间:2016-09-23 15:21:39

标签: powershell

我正在尝试将MSDOS脚本转换为使用Powershell。但是,我还没有弄清楚如何查看是否存在可变路径。

"如果存在%~dp0%MyNewPig%\ PigBreeds \%Type%%Breed%%Markings%_%EarNotch%\ nul goto skipthis"

你能帮忙吗?

失败者

1 个答案:

答案 0 :(得分:3)

它看起来像这样:

$ScriptRoot = Split-Path $script:MyInvocation.MyCommand.Path

if (Test-Path "$ScriptRoot\$PigBreed\Breeds\$MyNewPig_$PitBreed_$EarNotch\nul") {
    #Do whatever SKIPTHIS does here
}
相关问题