“怎么说?”;“如果存在”;Windows批处理脚本中的命令工作?

“怎么说?”;“如果存在”;Windows批处理脚本中的命令工作?,windows,batch-file,cmd,Windows,Batch File,Cmd,在Windows批处理脚本中,通常我们可以找到如果存在xxx或如果不存在xxx 此操作是否搜索计算机中的所有文件,或任何特定文件夹或路径中指定的xxx?如果未指定文件夹,它将在当前文件夹中查找。 但是你可以使用通配符。 例如: 如果当前文件夹中有扩展名为.png的文件,将输出文本 或者,您可以指定完整路径,例如 if exist d:\temp\*.png echo There are images there 如果尚未指定文件夹,它将在当前文件夹中查找。 但是你可以使用通配符。 例如: 如果

在Windows批处理脚本中,通常我们可以找到
如果存在xxx
如果不存在xxx


此操作是否搜索计算机中的所有文件,或任何特定文件夹或路径中指定的
xxx

如果未指定文件夹,它将在当前文件夹中查找。 但是你可以使用通配符。 例如:

如果当前文件夹中有扩展名为.png的文件,将输出文本

或者,您可以指定完整路径,例如

if exist d:\temp\*.png echo There are images there

如果尚未指定文件夹,它将在当前文件夹中查找。 但是你可以使用通配符。 例如:

如果当前文件夹中有扩展名为.png的文件,将输出文本

或者,您可以指定完整路径,例如

if exist d:\temp\*.png echo There are images there

如果你想让它检查是否有东西存在。然后让它在之后执行一些事情。那么这就是你如何做到的:

if exist "D:randomstuff\random\ranodom\allala.jpg" goto anotherLabel
if not exist "D:randomstuff\random\ranodom\allala.jpg" goto addwrite
:anotherlabel
:addwrite
MKDIR D:randomstuff\random\ranodom\
    echo this image doesn't exist> D:randomstuff\random\ranodom\allala.txt



or you can do this:
if exist randomfile.txt (
    for /f %%A in (randomfile.txt) do set text=%%A
    ) else (
    goto notexist.
基本上就是你做的。插入要检查的任何文件的路径(使用文件名)
然后,您只需将它设置为执行操作,无论它是创建、加载、覆盖、复制还是更改标签。等等。

如果你想让它检查是否有东西存在。然后让它在之后执行一些事情。那么这就是你如何做到的:

if exist "D:randomstuff\random\ranodom\allala.jpg" goto anotherLabel
if not exist "D:randomstuff\random\ranodom\allala.jpg" goto addwrite
:anotherlabel
:addwrite
MKDIR D:randomstuff\random\ranodom\
    echo this image doesn't exist> D:randomstuff\random\ranodom\allala.txt



or you can do this:
if exist randomfile.txt (
    for /f %%A in (randomfile.txt) do set text=%%A
    ) else (
    goto notexist.
基本上就是你做的。插入要检查的任何文件的路径(使用文件名)
然后,您只需将它设置为执行操作,无论它是创建、加载、覆盖、复制还是更改标签。等等。

感谢您的回答,因此它将搜索特定路径!我得到了它!谢谢你的回答,所以它会搜索特定的路径!我得到了它!谢谢你的回答!:)谢谢你的回答!:)