Page 1 of 1

I can't figure it out

Posted: 25 Aug 2011 07:01
by renzlo
Hi All,

I have created a batch file that monitors a specified directory, and I did it with the functions that I want(I am monitoring a zip file). Here's my script:

Code: Select all

:check
if exist "*.zip" (goto process) else (goto end)

:process
my commands here

:end
timeout /nobreak 180>nul
goto check


Now I want my batch file to process the command everytime it detects a zip file in the directory, disregarding the timeout command. Is this possible?

I just want my batch file to process command, without waiting for the timeout to finish, is there any other way?

Re: I can't figure it out

Posted: 25 Aug 2011 13:16
by aGerman
Not sure, but try something like that:

Code: Select all

@echo off &setlocal
for /l %%a in (0) do (
  for /f %%b in ('dir /a-d /b *.zip 2^>nul') do call :processZip "%%b"
)

:processZip
  echo Do something with %~1
goto :eof


for /l %%a in (0) do (... results in an infinite loop.

Regards
aGerman