I want to create a filewatcher in batch-file:
Watch for file in folderA (.zip) → unzip them to folderB (with same name) → and trigger a batch file → do the same for more incoming .zip files.
I checked related questions to this in StackOverflow but, I need some more help
:STARTPROCESS
CD /D %ROOT_DIR%
FOR /F "tokens=1-2 delims=." %%G in ('dir *.zip /b') do
(
REM unzip file
%SEVENZIP_PATH%\7z.exe x "%ROOT_DIR%" -o%UNZIP_FOLDER% -y >> %LOG%
echo %%G -- unzip complete
REM run batch1
:BATCH1
REM check ERROR from batch1 log --> i have a problem from here nothing below works
findstr /M "ERROR" %UNZIP_FOLDER%\%%G\Logs\*.log
If %ERRORLEVEL%==0 echo Error Found
move /Y "%UNZIP_FOLDER%\%%G" "%Folder1% >> %LOG%
goto STARTPROCESS
else
(
echo %%G Batch1 OK
goto BATCH2
)
REM run batch2
:BATCH2
REM check ERROR from batch2 log
findstr /M "Total Count : 0" %UNZIP_FOLDER%\%%G\Data\*_Output.log
If %ERRORLEVEL%==0 echo %%G Batch2 OK
goto STARTPROCESS
else
(
echo ERROR
move /Y "%UNZIP_FOLDER%\%%G\fileA.xml" "%UNZIP_FOLDER%\bin >> %LOG%
%SEVENZIP_PATH%\7z.exe a "%UNZIP_FOLDER%\%G%" -o%ZIP_FOLDER% -y >>%LOG%
)
)
timeout 60
goto STARTPROCESS
cmd /k