使用Windows Batch命令循环播放直到文件存在 [英] Loop until file exists using windows batch command

查看:81
本文介绍了使用Windows Batch命令循环播放直到文件存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将以下代码转换为Windows批处理命令?

how can i convert following code into windows batch command?

这是一个perl脚本,如果发现退出,它将在while循环中搜索文件.

Here is a perl script which is searching for a file in a while loop, if found it Exits.

use strict;
use warnings;
my $filename = 'something.txt'; 
while (1) {

if (-e $filename) {
print "File Exists!";
   exit;
   }

}

推荐答案

这是相当简单的翻译.该代码应该是不言自明的:

This is a fairly straight-forward translation. The code should be pretty self-explanatory:

@ECHO OFF
SET LookForFile="C:\Path\To\File.txt"

:CheckForFile
IF EXIST %LookForFile% GOTO FoundIt

REM If we get here, the file is not found.

REM Wait 60 seconds and then recheck.
REM If no delay is needed, comment/remove the timeout line.
TIMEOUT /T 60 >nul

GOTO CheckForFile


:FoundIt
ECHO Found: %LookForFile%

这篇关于使用Windows Batch命令循环播放直到文件存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆