在Windows批处理脚本中,我们通常可以找到if exist xxx
或if not exist xxx
。
这会搜索指定xxx
的计算机或任何特定文件夹或路径中的所有文件吗?
答案 0 :(得分:3)
如果您尚未指定文件夹,它将显示在当前文件夹中。 但是你可以使用通配符。 例如:
if exist *.png echo There are images here
将输出文本,如果在当前文件夹中有任何扩展名为.png
的文件或者您可以指定完整路径,例如
if exist d:\temp\*.png echo There are images there
答案 1 :(得分:0)
如果你想检查是否存在某些东西。然后让它在事后执行。那你就是这样做的:
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.
基本上你做的是什么。您将路径插入到您希望它检查的任何文件(如果存在)(带文件名)
然后你只需将它设置为动作,创建,添加,覆盖,复制,更改标签。等