作者:朱金灿
来源:https://blog.csdn.net/clever101
今天发现Windows下批处理if exist和del用法比较坑爹。
主要表现在if exist的格式要求比较严格,例子如下:
if exist "..\..\Intdir\Debug_x64\TestLog" (
del "..\..\Intdir\Debug_x64\TestLog\*.obj"
) else (
echo "not exist"
)
注意这里是有格式要求的,如下图:
还有echo后面的提示尽量不要用中文,用中文容易出错。
也可以写成简单一行:
@echo off
if exist "../../Intdir/Debug_x64/TestLog" (del "..\..\Intdir\Debug_x64\TestLog\*.obj") else echo Debug_x64不存在