I can't figure it out

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
renzlo
Posts: 116
Joined: 03 May 2011 19:06

I can't figure it out

#1 Post by renzlo » 25 Aug 2011 07:01

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?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: I can't figure it out

#2 Post by aGerman » 25 Aug 2011 13:16

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

Post Reply