@echo OFF
echo .
echo This program is free software: you can redistribute it and/or modify
echo it under the terms of the GNU General Public License as published by
echo the Free Software Foundation, either version 3 of the License, or
echo (at your option) any later version.
echo .
echo This program is distributed in the hope that it will be useful,
echo but WITHOUT ANY WARRANTY; without even the implied warranty of
echo MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
echo GNU General Public License for more details.
echo .
echo You should have received a copy of the GNU General Public License
echo along with this program. If not, see .
echo .
echo Copyright ^(c^) Bram Neijt ^
echo with help and advice from K-Elf.nl - The KELF team.
echo .
echo .
echo This program will monitor for ORDER.APP in your temporary files
echo and if an ORDER.ALB appears next to ORDER.APP, will copy ORDER.APP
echo to a local file
echo .
echo If you agree to all this, press any key to continue
pause
:findOrderAppFileLabel
echo Looking for ORDER.APP to appear
FOR /R "%TMP%" %%F IN (*ORDER.APP) DO set orderAppFile=%%F
if [%orderAppFile%] == [] (
echo no ORDER.APP found yet
TIMEOUT /T 2 /NOBREAK
goto :findOrderAppFileLabel
)
for %%f in (%orderAppFile%) do set orderAppDirectory=%%~dpf
set outputFile=order_%RANDOM%.pdf
echo Found %orderAppFile%
echo Will monitor %orderAppDirectory%
:waitForOrderAlbLabel
IF EXIST %orderAppDirectory%\ORDER.ALB (
echo ORDER.ALB seen, copying ORDER.APP
copy %orderAppFile% %outputFile%
echo Copied file to: %outputFile%
) ELSE (
IF EXIST %orderAppFile% (
echo no ORDER.ALB yet
TIMEOUT /T 2 /NOBREAK
goto :waitForOrderAlbLabel
) ELSE (
echo LOST %orderAppFile%
echo Starting over
goto :findOrderAppFileLabel
)
)
echo Hopefully this all worked out, press any key to exit
pause