【问题标题】:how to detect the existence of a txt file using a batch commands如何使用批处理命令检测txt文件的存在
【发布时间】:2016-07-30 13:05:29
【问题描述】:

我需要编写一个批处理脚本才能在 Windows 上运行。

我将安排该文件在服务器上每分钟运行一次,以测试该服务器上是否存在 txt 文件,然后将其删除。

批处理文件的作用是:

检查服务器上是否存在 txt 文件,如果在该位置找到该文件,1) 删除它 2) 运行一些其他操作。

我知道那些动作是什么。我已经得到了它的代码。

我只需要有关如何检查该 txt 文件是否存在以及如果存在如何删除它的帮助。

我需要什么命令?

如果您能提出一些建议,我将不胜感激。

【问题讨论】:

标签: windows batch-file command-prompt


【解决方案1】:

Rob Van Der Woude 的批处理文件参考是一个很好的来源: http://www.robvanderwoude.com/if.php 示例展示了如何实现这一目标。

IF [NOT] EXIST filename command

这样的……

IF EXIST file.txt Start script.bat

或者……

IF EXIST file.txt GOTO somelabel

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-24
    • 2013-06-16
    相关资源
    最近更新 更多