2016-01-20 50 views

回答

3

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

if exist *.png echo There are images here 

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

,或者你可以指定一个完整路径的任何文件,例如

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

谢谢你的回答,所以它会搜索某个路径!我知道了! –

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. 

基本上你在做什么。你插入路径到你想要检查的文件是否存在(带有文件名) ,然后你将它设置为执行一个动作来创建,添加,覆盖,复制,更改标签。等等。

+0

谢谢你的回答! :) –

相关问题