echo Y | rd %builddir% /s

if not exist %builddir%\nul md %builddir%
set ErrorText=%builddir%
if not exist %builddir%\nul GOTO ERROR

set CreateDir=DOCS
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=HELP
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=HELP\CBUILDER
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=HELP\DELPHI
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=HPP3
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=HPP4
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=HPP5
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=HPP6
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=HPP3TR
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=HPP4TR
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=HPP5TR
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=HPP6VTR
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=HPP6CTR
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=DCU3
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=DCU4
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=DCU5
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=DCU6
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=DCU6vtr
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=DCU6ctr
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=OBJ3
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=OBJ4
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=OBJ5
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=OBJ6
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=OBJ3TR
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=OBJ4TR
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=OBJ5TR
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=OBJ6VTR
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=OBJ6CTR
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=REDIST
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\customer
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\xmldocs
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\Delphi
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\Delphi\EXMLPro
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\Delphi\NoFilter
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\Delphi\TextView
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\Delphi\WrkOrder
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\Delphi\XMLTest
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\Delphi\XSLDemo
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr3
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr3\TextView
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

rem EXMLPro is not available for BCB3
rem set CreateDir=Examples\CBuildr3\EXMLPro
rem if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
rem set ErrorText=%builddir%\%CreateDir%
rem if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr3\XMLTest
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr4
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr4\EXMLPro
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr4\TextView
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr4\XMLTest
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr5
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr5\EXMLPro
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr5\TextView
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr5\XMLTest
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr6
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr6\EXMLPro
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr6\TextView
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=Examples\CBuildr6\XMLTest
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=REDIST
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP\FULL
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP\DISKPATCH
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP\SINGLEFILEPATCH
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP\D3TRIAL
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP\D4TRIAL
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP\D5TRIAL
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP\D6VCLTRIAL
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP\D6CLXTRIAL
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP\C3TRIAL
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP\C4TRIAL
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP\C5TRIAL
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP\C6VCLTRIAL
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=SETUP\C6CLXTRIAL
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

set CreateDir=TRIALRUN
if not exist %builddir%\%CreateDir%\nul md %builddir%\%CreateDir%
set ErrorText=%builddir%\%CreateDir%
if not exist %builddir%\%CreateDir%\nul GOTO ERROR

ECHO Directories built

GOTO FINISH

:ERROR
ECHO Error creating %ERRORTEXT% directory.
pause

:FINISH
set ErrorText=
set CreateDir=
