Speeding Up the Batch Wizard

If you are checking documents in local folders, such as by folder targets, and want to only check documents that have changed since the last validation (unless they had errors or warnings in which case they will always be rechecked), then the following Batch Wizard functions can be used to create "cache files" that are used as a type of cache to remember whether a document needs to be re-validated the next time the Batch Wizard job is run.

Additional information:

Note that this is not designed for HTTP or HTTPS targets; only local documents on the local file system.

Because this example uses writeFile() and deleteFile() functions, you must enable potentially destructive functions in the Config Files Options Page for it to work.

The code below should be placed in a text file, and the text file specified in the Target List Options Tab as the user functions file for each target list that you want it applied to.

Set $cachefolder in onBeforeMainStart() to the folder where the "cache files" will be stored and make sure HTML Validator will have write permission there.

If a document is changed within 1 minute of the cache file creation, then it may not be recognized as changed during the next run.


 * Set $cachefolder in onBeforeMainStart()
 *  to the folder to use to store data
 *  (it must end in a backslash)
function onBeforeMainStart() {
 $cachefolder='T:\\cache\\'; // cache files stored here
 if !existsFolder($cachefolder) {
  ProgressMessage('$cachefolder does not exist: '+$cachefolder,2);

 if !isDestructiveFunctionsEnabled {
  ProgressMessage('This TNPL script requires potentially destructive functions to be enabled but they\'re not (enable in the Validator Engine Options, Config File page).',2);
function onTargetCanAdd() {
 if !$otca_add return; // don't override if target's default is not to add
// ProgressMessage('$cachefile: '+$cachefile);
 if $cfinfo.isSet() { // if there's a cache file
  if $tinfo.isSet() {
   if $tinfo.lastwrite_year>$cfinfo.lastwrite_year { $otca_add=true; }
   else { if $tinfo.lastwrite_year==$cfinfo.lastwrite_year {
   if $tinfo.lastwrite_month>$cfinfo.lastwrite_month { $otca_add=true; }
   else { if $tinfo.lastwrite_month==$cfinfo.lastwrite_month {
   if $tinfo.lastwrite_day>$cfinfo.lastwrite_day { $otca_add=true; }
   else { if $tinfo.lastwrite_day==$cfinfo.lastwrite_day {
   if $tinfo.lastwrite_hour>$cfinfo.lastwrite_hour { $otca_add=true; }
   else { if $tinfo.lastwrite_hour==$cfinfo.lastwrite_hour {
   if $tinfo.lastwrite_min>$cfinfo.lastwrite_min { $otca_add=true; }
function onTargetProcessed() {
 if getValueInt(1) || getValueInt(2) { // if has errors or warnings
 else {
  if writeFile($cachefile,'',2)<0 { // create an empty file
   ProgressMessage('Error writing $cachefile: '+$cachefile,2);