rem oo.btm defrag all drives, uses TCC command processor
rem mark files as busy so automatic scheduled background tasks using files will abort.
rem bypassclean in an option
call E:\env\busy.bat

rem turn off file indexing
call E:\env\copernicclose.bat

if "%1" == "bypassclean" goto bypassclean
rem delete junk files, customised for my machine.
batikacer.exe

rem touch dirs with today's date so the defrag will move them together.
echo touching dirs
touchdirs.exe -q C: D: E: F: G:

:bypassclean

rem restart the O&O service
call oor.bat

rem possible commands ANALYSIS, OPTIMIZE, QUICK, COMPLETE, COMPNAME, COMPACC, COMPMOD, FRAGFILES, SPACE, STEALTH

rem do the work in stages, so that if we abort early, we have done the most important work.

@echo  %_date %_time
OODCMD /QUICK:C,D,E,F,G
rem try again
if errorlevel 1 call oor.bat

rem no longer do /OPTIMIZE

rem call me over to poke Copernic to reindex
honk.exe "C:\Windows\media\Windows Print complete.wav"
rem turn on file indexing
call E:\env\copernicstart.bat

@echo  %_date %_time
echo hit any key to stop indexing
rem give 15 mins = 900 secs for indexing.
delay 900  /B

rem turn off file indexing
call E:\env\copernicclose.bat

rem final thorough defrag
@echo  %_date %_time
OODCMD /COMPLETE:D,E,F,G
if errorlevel 1 call oor.bat
@echo  %_date %_time
OODCMD /COMPLETE:C
@echo  %_date %_time

rem turn on file indexing  for second time
call E:\env\copernicstart.bat

@echo  %_date %_time
echo hit any key to stop indexing
rem give 120 mins = 7200 secs for indexing.
delay 7200  /B

rem turn off file indexing
call E:\env\copernicclose.bat

rem leave Copernic file indexing off.

rem allow background tasks access to files again
call E:\env\unbusy.bat

exit
rem -30-