使用 windows 批处理命令循环直到文件存在

Loop until file exists using windows batch command

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

这是一个 perl 脚本,它在 while 循环中搜索文件,如果找到则退出。

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

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

}

这是一个相当直接的翻译。代码应该是不言自明的:

@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%