@echo off
rem requires Take Command script processor installed. see http://mindprod.com/jgloss/takecommand.html
rem run blout once for each of the *.java *.list *.txt and *.bat ... files
rem in the current directory
rem to remove excess blank lines
rem param "tree" to do whole tree, not just current dir
echo removing excess blank lines on all files in %_CWD directory
rem -compact on command line removes all blanks not just excess ones.
set tree=false
if "%1" == "tree"  set tree=true
if "%1" == "-tree" set tree=true
if "%1" == "/tree" set tree=true
if "%2" == "tree"  set tree=true
if "%2" == "-tree" set tree=true
if "%2" == "/tree" set tree=true

if "%tree" == "true"   echo and all subdirectories too
if "%tree" == "false"  echo without subdirectories

set compact=
if "%1" == "compact"  set compact=-compact
if "%1" == "/compact" set compact=-compact
if "%1" == "-compact" set compact=-compact
if "%2" == "compact"  set compact=-compact
if "%2" == "/compact" set compact=-compact
if "%2" == "-compact" set compact=-compact
if "%compact" == "-compact"   echo compacting out all blank lines, not just excess.

rem don't reformat, collapse or expand onto more lines.
set exts=*.asm;*.bat;*.batfrag;*.btm;*.btmfrag;*.c;*.cpp;*.dtd;*.dtdfrag;*.h;*.hpp;*.html;*.htmlfrag;*.java;*.javafrag;*.jnlp;*.jnlpfrag;*.list;*.pml;*.sql;*.sqlfrag;*.txt;*.use;*.xml;*.xmlfrag;*.xsd;*.xsdfrag
if "%tree" == "true" ( for /r /h /a:-d  %f in (%exts) do blout.exe %compact %f
) else (
for /h /a:-d %f in (%exts) do blout.exe %f )

rem untouch files we just changed
if "%tree" == "true" ( untouch -q -s .
) else (
untouch -q . )

rem -30