我需要运行Windows批处理文件来检查是否存在一堆文件。我写了以下批处理文件代码:
dir
if exist {"help/user/Content/learning_home.htm"} { echo file exists} ELSE {echo File Deleted}
if exist {"./archibus.war"} {echo File not deleted!} ELSE {echo File Deleted}
if exist {"./build.xml"} { echo file exists} ELSE {echo File Deleted}
当我执行批处理文件时,目录列表会正确显示,但其余命令只会显示回命令行。
我觉得我错过了一些基本的东西。任何建议都将不胜感激。
答案 0 :(得分:3)
使用常规括号而不是大括号。
if exist "help/user/Content/learning_home.htm" (echo file exists) ELSE (echo File Deleted)
if exist "./archibus.war" (echo File not deleted!) ELSE (echo File Deleted)
if exist "./build.xml" (echo file exists) ELSE (echo File Deleted)