如何从批处理文件中检查文件是否存在 [英] How to check if a file exists from inside a batch file
本文介绍了如何从批处理文件中检查文件是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
仅当某个文件存在时,我才需要运行实用程序.如何在 Windows 批处理中执行此操作?
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>
例如,如果文件存在,这将在 autoexec.bat 上打开记事本:
for example, this opens notepad on autoexec.bat, if the file exists:
if exist c:autoexec.bat notepad c:autoexec.bat
这篇关于如何从批处理文件中检查文件是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文