我想要检查某个文件夹(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 :NOWINDIRTry 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 :NOWINDIRtrailing backslash ('\') seems to be enough to distinguish between directories and ordinary files.
更多推荐
发布评论