set n_ver=1
set FILE1TOZIP=".\Logs"
set FILE2TOZIP=".\Experts"
set FILE3TOZIP=".\Indicators"
set FILE4TOZIP=".\Include"
set FILE5TOZIP=".\Scripts"

:boucle
set ZIPEDFILE="C:\Users\Administrateur\AppData\Roaming\MetaQuotes\Terminal\B3511AE7AE29D20268E67E28E5D8DF10\MQL4\Versions mq4-mqh (%n_ver%).zip"
IF EXIST %ZIPEDFILE% (
set /a n_ver=%n_ver% + 1
goto boucle )

set COPYDIR=C:\Users\Administrateur\AppData\Roaming\MetaQuotes\Terminal\B3511AE7AE29D20268E67E28E5D8DF10\MQL4\temp738
mkdir %COPYDIR%
copy %FILE1TOZIP%\*.* %COPYDIR%\%FILE1TOZIP%\*.*
copy %FILE2TOZIP%\*.mq4 %COPYDIR%\%FILE2TOZIP%\*.*
copy %FILE3TOZIP%\*.mq4 %COPYDIR%\%FILE3TOZIP%\*.*
copy %FILE4TOZIP%\*.* %COPYDIR%\%FILE4TOZIP%\*.*
copy %FILE5TOZIP%\*.mq4 %COPYDIR%\%FILE5TOZIP%\*.*
set tsize=7000
:exit

CScript _zipIt.vbs  %COPYDIR%  %ZIPEDFILE% %tsize%
rem pause

call :size_file %ZIPEDFILE%
echo file is %size%
if %size% gtr 1000 goto end
set /a tsize=%tsize% + 2000
goto exit

:end
del /s /q %COPYDIR%\%FILE1TOZIP%\*.*
del /s /q %COPYDIR%\%FILE2TOZIP%\*.*
del /s /q %COPYDIR%\%FILE3TOZIP%\*.*
del /s /q %COPYDIR%\%FILE4TOZIP%\*.*
del /s /q %COPYDIR%\%FILE5TOZIP%\*.*
rmdir /s /q %COPYDIR%\%FILE1TOZIP%
rmdir /s /q %COPYDIR%\%FILE2TOZIP%
rmdir /s /q %COPYDIR%\%FILE3TOZIP%
rmdir /s /q %COPYDIR%\%FILE4TOZIP%
rmdir /s /q %COPYDIR%\%FILE5TOZIP%
rmdir %COPYDIR%
exit

:size_file
set size=%~z1
