我是批处理命令的新手。我写了以下代码:
for /D %%G in ("C:\CI\workspace\MP*") do (
if exists "%%~nG\DirecotoryPortal\" (
CD "DirecotoryPortal"
echo DirectoryPortal Exists
)
)
此时出现意外的错误“%~nG\DirecotoryPortal”。 我不知道如何在循环中使用 %%G 。我想采用这个路径并与“DirecotoryPortal”连接并检查该目录是否存在。
这应该有效,并且应该迭代 C:\CI\workspace 中与模式 MP* 匹配的目录。
for /D %%G in ("C:\CI\workspace\MP*") do (
if exist "%%G\DirectoryPortal\" (
CD /D "%%G\DirectoryPortal"
echo DirectoryPortal Exists in %%G
)
)