anchor.diff:  GOTO :eof
   
   :USAGE
  -echo Usage: "stdout-log" "stderr-log" "pin" "label" "base-path"
  +set usage="Usage: %0 ^<pin^> ^<label^> ^<base-path^> ^<stdout-log^> [stderr-log]"
  +set  note="All log messages are redirected to stdout-log if stderr-log is not specified."
  +echo %usage:"=%
  +echo %note:"=%
  
positive.code: rem   - xxxx-2013-10-01.dat
  rem   - xxxx-2013-10-01.log
  rem
  rem This script is executed with the following arguments...
  rem sc-hsm-ultralite-signer.cmd out.log err.log 123456 sign0 d:\data
  rem 
  rem If today's date is 2013-10-01, the following commands will be executed...
  rem sc-hsm-ultralite-signer.exe 123456 sign0 d:\data\2013-10\xxxx-2013-10-01.dat >> out.log 2>> err.log
  rem sc-hsm-ultralite-signer.exe 123456 sign0 d:\data\2013-10\xxxx-2013-10-01.log >> out.log 2>> err.log
  rem sc-hsm-ultralite-signer.exe 123456 sign0 d:\data\2013-09\xxxx-2013-09-30.dat >> out.log 2>> err.log
  rem 
  rem This script requires the unix date utility.
  rem Download a Windows implementation from http://sourceforge.net/projects/unxutils/
  rem Rename date.exe to unix_date.exe to avoid conflict with the native 'date' command.
  
  if "%1" == "--rotate" GOTO :ROTATE
  if "%1" == "" GOTO :USAGE
  if "%2" == "" GOTO :USAGE
  if "%3" == "" GOTO :USAGE
  if "%4" == "" GOTO :USAGE
  if "%5" == "" GOTO :USAGE
  if exist "%1" CMD /C ""%0" --rotate %1"
  if exist "%2" CMD /C ""%0" --rotate %2"
  
  for /F "delims=" %%i in ('unix_date.exe +%%Y-%%m-%%d') do set CUR_DAY=%%i
  for /F "delims=" %%i in ('unix_date.exe --date="%CUR_DAY%" +%%Y-%%m') do set CUR_DAY_MTH=%%i
  for /F "delims=" %%i in ('unix_date.exe --date="%CUR_DAY% -1 day" +%%Y-%%m-%%d') do set PRV_DAY=%%i
  for /F "delims=" %%i in ('unix_date.exe --date="%PRV_DAY%" +%%Y-%%m') do set PRV_DAY_MTH=%%i
  set exe=%~dpn0%.exe
  rem for /F "delims=" %%I in ('dir /b %5\*%CUR_DAY%* %5\*%PRV_DAY%* 2^>nul ^| findstr /v /i "\<\. \.p7s\>"') do CALL %exe% %3 %4 %5\%%~nxI               >> %1 2>> %2
      for /F "delims=" %%I in ('dir /b %5\%CUR_DAY_MTH%\*%CUR_DAY%*  2^>nul ^| findstr /v /i "\<\. \.p7s\>"') do CALL %exe% %3 %4 %5\%CUR_DAY_MTH%\%%~nxI >> %1 2>> %2
      for /F "delims=" %%I in ('dir /b %5\%PRV_DAY_MTH%\*%PRV_DAY%*  2^>nul ^| findstr /v /i "\<\. \.p7s\>"') do CALL %exe% %3 %4 %5\%PRV_DAY_MTH%\%%~nxI >> %1 2>> %2
  GOTO :eof
  
  :ROTATE
  
negative.code: @echo off
  setlocal enableDelayedExpansion
  
  rem This is a convenience script for running sc-hsm-ultralite-signer.
  rem 
  rem This script also automates finding all files from today and 
  rem yesterday. It recursively searches for all files matching the regex
  rem yyyy-mm-dd where yyyy-mm-dd is once today's date and once yesterday's 
  rem date.
  rem 
  rem It further speeds up processing, by skipping old folders. If a 
  rem folder contains a date in the format yyyy-mm, this script will only 
  rem recurse into the folder if the name matches either today's month 
  rem or yesterday's month.
  rem 
  rem If a folder does NOT match the regex yyyy-mm, it will unconditionally 
  rem recurse into that folder looking for files from yesterday or today.
  rem 
  rem yyyy-mm will always be the same folder for yesterday and today except 
  rem for the first day of any particular month.
  rem Uncomment the first "for" command below to make the script also
  