使用.bat文件检查文件夹是否存在[closed](Checking if a folder exists using a .bat file [closed])

系统教程 行业动态 更新时间:2024-06-14 17:03:52
使用.bat文件检查文件夹是否存在[closed](Checking if a folder exists using a .bat file [closed])

我想要检查某个文件夹(FolderA)是否存在,如果是,则显示一条消息,然后退出批处理文件。

如果FolderA不存在,我想检查另一个文件夹(FolderB)是否存在。 如果FolderB不存在,应该显示一条消息并创建文件夹,如果FolderB存在,则应该显示一条消息。

有人有任何想法的代码,我可以简单地使用记事本创建一个批处理文件,以允许我这样做?

所有这一切都需要在一个.bat文件中完成。

I would like to be able to check if a certain folder (FolderA) exists and if so, for a message to be displayed and then the batch file to be exited.

If FolderA does not exist, I would then like to check if another folder (FolderB) exists. If FolderB does not exist, a message should be displayed and the folder should be created, and if FolderB does exist, a message should be displayed saying so.

Does anybody have any idea on the code I could simply use on notepad to create a batch file to allow me to do this?

All of this needs to be done in one .bat file.

最满意答案

尝试使用这个文件:

IF EXIST yourfilename ( echo Yes ) ELSE ( echo No )

用你的文件名替换你的文件名。

对于dir,请看http://support.microsoft.com/kb/65994

C: IF NOT EXIST C:\WIN\NUL GOTO NOWINDIR CD \WIN :NOWINDIR

Try using this for a file:

IF EXIST yourfilename ( echo Yes ) ELSE ( echo No )

Replace yourfilename with what you file name is.

For a dir look at this https://jeffpar.github.io/kbarchive/kb/065/Q65994/

C: IF NOT EXIST C:\WIN\ GOTO NOWINDIR CD \WIN :NOWINDIR

trailing backslash ('\') seems to be enough to distinguish between directories and ordinary files.

更多推荐

本文发布于:2023-04-24 12:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/60be71b1192c3af9d9eb99511ac739a0.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是否存在   文件夹   文件   bat   closed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!