如何检查是否一个文件从一个批处理文件中存在 [英] How to check if a file exists from inside a batch file
本文介绍了如何检查是否一个文件从一个批处理文件中存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要的,如果某个文件存在只能运行一个程序。我该怎么做这在Windows批处理?
解决方案
是否存在<此处&GT插入文件名; (
REM文件存在
)其他(
REM文件不存在
)
或者在一行(如果只有一个动作需要进行):
如果有<插入文件名称> <作用>
例如,这将打开记事本AUTOEXEC.BAT,如果文件存在:
是否存在C:\\ autoexec.bat中记事本C:\\ AUTOEXEC.BAT
I need to run a utility only if a certain file exists. How do I do this in Windows batch?
解决方案
if exist <insert file name here> (
rem file exists
) else (
rem file doesn't exist
)
Or on a single line (if only a single action needs to occur):
if exist <insert file name here> <action>
for example, this opens notepad on autoexec.bat, if the file exists:
if exist c:\autoexec.bat notepad c:\autoexec.bat
这篇关于如何检查是否一个文件从一个批处理文件中存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文