如何将以下代码转换为windows batch命令?
这是一个perl脚本,它在while循环中搜索文件,如果发现它退出。
use strict;
use warnings;
my $filename = 'something.txt';
while (1) {
if (-e $filename) {
print "File Exists!";
exit;
}
}
答案 0 :(得分:17)
这是一个相当简单的翻译。代码应该是不言自明的:
@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%