Loop until the file is created using the windows batch command

how can i convert the following code to windows command command?

Here is a perl script that looks for a file in a while loop if it is found.

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

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

}
+4
source share
1 answer

This is a fairly direct translation. The code should be pretty straightforward:

@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%
+13
source

Source: https://habr.com/ru/post/1570898/


All Articles