美文网首页
Windows Batch判断文件目录是否存在

Windows Batch判断文件目录是否存在

作者: CodingCode | 来源:发表于2023-01-23 02:08 被阅读0次

文件存在

set file=...
if exist "%file%" (
   echo "file %file% exist"
)

文件不存在

set file=...
if not exist "%file%" (
   echo "file %file% exist"
)

目录存在

set file=...
if exist "%file%\" (
   echo "file %file% exist"
)

目录不存在

set file=...
if exist "%file%\" (
   echo "file %file% exist"
)

没有专门的参数区分文件还是目录,主要通过文件名后面加一个""路径标识来表面这是一个目录。

相关文章

网友评论

      本文标题:Windows Batch判断文件目录是否存在

      本文链接:https://www.haomeiwen.com/subject/minfhdtx.html