如何查找批处理文件中是否存在"*.err"文件类型



我如何找到 *.err文件类型存在或不存在于批处理文件中。我正在使用以下代码查找文件类型的存在。

if [ -f $"*.err" ]
then
   echo "File Type exists"
else
   echo "File Type does not exists"
fi

我认为此代码不准确。您可以纠正此问题以找到文件类型吗?

在批处理文件中脚本看起来像这样:

@Echo off
Rem DistPath Is Where you Want to check for file type
Set "DistPath=%UserProfile%Desktop"
If Exist "%DistPath%*.err" ( Echo File Type exists
) Else (
      Echo File Type does not exists
)
pause

编辑:

尝试这个&添加需要在" executeFlag"之间执行的代码&" goto eof"。

@Echo off
If Exist "*.err" ( 
    Goto EOF
) Else (
    Goto ExecuteFlag
)
pause
Exit
Rem Put Your Code Down Here
:ExecuteFlag
<<< Your Code Here >>>
Goto EOF

,但如果您将继续&amp;添加很多行,这更好

If Exist "*.err" Goto :EOF 

然后添加代码的其余部分,假设您找不到文件。因此,如果文件存在,则代码将结束,否则它将根据您的代码处理缺失的文件类型

相关内容

最新更新