gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 23:24:51 26 4
gpt4 key购买 nike

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

“如果存在%〜dp0%MyNewPig%\ PigBreeds \%Type %% Breed %% Markings%_%EarNotch%\ nul则跳过此”

你能帮我吗?

弱者

最佳答案

它看起来像这样:

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

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

关于powershell - 如何使用powershell命令检查变量目录是否存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39664334/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com