Automatically do Verify/Repair - BackUp optimize?

Is there a smart way to make Verify/Repair and BackUp Optimize automatic?

I have Hazel, Keyboard Maestro and LaunchBar but rather not invent the wheel again if done.

One possibility might be to add a script to the scripts menu to perform both actions:


tell application id "DNtp"
	try
		set theDatabase to current database
		set theErrors to (verify database theDatabase) as integer
		if theErrors = 0 then
			optimize database theDatabase
		else
			error "Database \"" & (name of theDatabase) & "\" is damaged (" & (theErrors as string) & " issues)."
		end if
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell