@echo off & setlocal enableextensions & echo.

:: finish.bat for citeswood. Revised 4/4/2023. M.J. Dallwitz.

if '%1' neq '' goto getpar

:usage
echo Copies files, clears archive attributes in output folders,
echo deletes temporary files, and converts file names to lower case.
echo Called by runlan.bat.
echo Usage: FINISH language
echo    where 'language' is 'en', 'de', 'fr', or 'es'.
exit /b 1

:getpar
if "%1" equ "/?" goto usage
for %%p in (de DE) do if %%p==%1 goto de
for %%p in (en EN) do if %%p==%1 goto en
for %%p in (es ES) do if %%p==%1 goto es
for %%p in (fr FR) do if %%p==%1 goto fr
goto usage

:de
set lan=de
goto start

:en
set lan=en
goto start

:es
set lan=es
goto start

:fr
set lan=fr
goto start

:start

echo Copying files and tidying.

call chkdir_ %lan% || goto abort

set w=www
set i=info
set t=tech
set r=rtf

call chkdir_ %lan%\%w% || goto abort
call chkdir_ %lan%\%i% || goto abort
call chkdir_ %lan%\%t% || goto abort

set copfil_=0
call copfiq_ style.css %lan%
call copfiq_ deltlogo.gif %lan%

cd %lan%
call copfiq_ style.css %w%
call copfiq_ deltlogo.gif %w%

cd %t%
call copfiq_ *.rtf ..\%i%
if %copfil_% neq 0 goto abort

cd ..
attrib -a *.gif > nul
attrib -a *.css > nul
attrib -a %w%\*.* > nul
attrib -a %i%\*.* > nul
attrib -a %r%\*.* > nul

cd ..
if exist *.bak del *.bak > nul
if exist *.lst del *.lst > nul
if exist *.tmp del *.tmp > nul
if exist *.wbk del *.wbk > nul
if exist temp.* del temp.* > nul
if exist temp_files\ rd /s/q temp_files
call lcase

goto end

:abort
exit /b 1

:end
exit /b 0
