@echo off & setlocal enableextensions & echo.

:: webgenm.bat for citeswood. Revised 21/7/2019. M.J. Dallwitz.

if "%1%" equ "/?" (
   echo Generates files for uploading the main folder of a DELTA
   echo Web package with language subfolders that include files
   echo that are not automatically generated.
   exit /b 0
   )

:: Set an abbreviation for name of the dataset. Must not include blanks.
set "dataname=citeswood"

:: Set the URL of the Web folder (used by webink_.bat).
set "webdir=https://www.delta-intkey.com/%dataname%/"
:: Set the local folder from which the dataset will be uploaded.
call chkdir_ %up% || goto abort
set "updir=%up%\%dataname%"

call chkdiq_ %updir% || md %updir%
call chkdir_ %updir% || goto abort

set "zpd=%dataname%data.zip"
set "zpw=%cd%\%dataname%.zip"

call lcase

:: Check presence of data files.
if exist addfil_.tmp del addfil_.tmp > nul
call webaddm data || goto abort

:: Zip data files, including subfolders.
if exist %zpd% del %zpd% > nul
zip -Doq %zpd% * de\* en\* es\* fr\* de\tech\* en\tech\* es\tech\* fr\tech\* -i@addfil_.tmp
echo Data files processed.

:: Check presence of Web files.
if exist addfil_.tmp del addfil_.tmp > nul
call webaddm general || goto abort
if exist %zpd% call addfil_ %zpd% || goto abort

:: Zip Web files.
if exist %zpw% del %zpw% > nul
call zip -Doq %zpw% * -i@addfil_.tmp
echo Web files processed.

goto finish

:abort
echo.
echo     ***** 'webgenm.bat' failed.
exit /b 1

:finish
echo.
call showfilepathsize_ "%zpw%"
if exist addfil_.tmp del addfil_.tmp > nul
if exist %zpd% del %zpd% > nul

cd /d %updir% || exit /b 1
call unzip -ouq "%zpw%"
sleep 1 /quiet
del "%zpw%"

exit /b 0
