 @echo off
 :: Copyright 1998, Ted Davis - all rights reserved
 if not %pass%!==! goto %pass%
 set pass=pass2
 set count=!!
 set flag=
 set pattern=
 set realdir=
 set testdir=
 set olddircmd=%dircmd%
 set dircmd=
 set a=
 set ostype=DOS
 if %OS%!==Windows_NT! set ostype=NT
 set null=nul
 if %ostype%==NT set null=
 :loop0
 set pattern=%pattern%%1
 if %2!==! goto cont0
 set pattern=%pattern% 
 shift
 set flag="
 goto loop0
 :cont0
 if not exist %flag%%pattern%%null%%flag% goto error
 echo %pattern%> }1{.dat
 dir %flag%%pattern%*.*%flag% /a:d | find "Volume in drive" > }2{.bat
 echo set !=%%3> volume.bat
 call }2{
 set !=%!%:\
 set realdir=%!%
 :outerloop
 dir %flag%%realdir%*.*%flag% /a:d /b > }3{.dat
 echo.>> }3{.dat
 date < }3{.dat | find "En" > }4{.dat
 echo exit>> }4{.dat
 command /e:1024 < }4{.dat >> nul
 call }5{.bat
 echo %realdir%> }6{.dat
 find /i "%pattern%" }6{.dat > nul
 if not errorlevel 1 goto display
if %count%==!!!!!!!! goto end
 set count=%count%!
 goto outerloop
 :pass2
 if %ostype%==NT goto nt1
 if %4!==! goto end
 goto cont11
 :nt1
 if %5!==! goto end
 :cont11
 set a=%realdir%
 set testdir=
 :innerloop
 if %ostype%==DOS set a=%a%%4
 if %ostype%==NT set a=%a%%5
 if %ostype%==DOS set testdir=%testdir%%4
 if %ostype%==NT set testdir=%testdir%%5
 shift
 if %ostype%==NT goto nt2
 if %4!==! goto cont1
 goto cont12
 :nt2
 if %5!==! goto cont1
 :cont12
 set a=%a% 
 set testdir=%testdir% 
 goto innerloop
 :cont1
 set a=%a%\
 find /i "%a%" }1{.dat > nul
 if errorlevel 1 goto end
 echo set %count%=%testdir%> }5{.bat
 echo set realdir=%a%>> }5{.bat
 goto end
 :display
 :cleanup
 set dircmd=%olddircmd%
 set maxcount=%count%
 set count=!
 echo The elements in %pattern% are
 :cleancountloop
 set %count%=
 if %count%==%maxcount% goto cleancont
 set count=%count%!
 echo echo %%%count%%%>}5{.bat
 call }5{
 set %count%=
 goto cleancountloop
 :cleancont
 set pass=
 set ostype=
 set count=
 set maxcount=
 set pattern=
 set realdir=
 set testdir=
 set a=
 set flag=
 set olddircmd=
 del }1{.dat
 del }2{.bat
 del }3{.dat
 del }4{.dat
 del }5{.bat
 del }6{.dat
 goto end
 :error
 echo.
 echo.
 echo ERROR Report: %pattern% 
 echo does not exist, lacks a trailing '\' or has some other error.
 :end
