Mih*_*hir 7 command file batch-file line while-loop
如何将以下代码转换为Windows批处理命令?
这是一个perl脚本,它在while循环中搜索文件,如果发现它退出.
use strict;
use warnings;
my $filename = 'something.txt';
while (1) {
if (-e $filename) {
print "File Exists!";
exit;
}
}
Run Code Online (Sandbox Code Playgroud)
Jas*_*ner 19
这是一个相当直接的翻译.代码应该是不言自明的:
@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%
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
23576 次 |
最近记录: |