问题描述
我希望能够检查某个文件夹(FolderA)是否存在,如果存在,则显示一条消息,然后退出该批处理文件.
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.
如果FolderA不存在,那么我想检查是否存在另一个文件夹(FolderB).如果FolderB不存在,则应显示一条消息并创建该文件夹,如果FolderB存在,则应显示一条消息.
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?
所有这些操作都需要在一个.bat
文件中完成.
All of this needs to be done in one .bat
file.
推荐答案
尝试使用此功能:
IF EXIST yourfilename (
echo Yes
) ELSE (
echo No
)
用文件名替换您的文件名.
有关目录,请查看此 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.
这篇关于使用.bat文件检查文件夹是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!