:: Desearch.bat - Processes files created before given date, using :: procedure named on command line. :: Tom lavedas :: http://www.pressroom.com/~tglbatch @%3 echo %dbgd% off if '%1==' goto End Nothing to do. if '%2==' %0 %1 %temp%.\~process.bat % Default process name % :; Get today's date echo @prompt if '%%%%2==' %%%%0=$D$_set _D=%%%%2$_ > %temp%.\{A}.bat %comspec% /e:2048 /c %temp%.\{A}.bat > %temp%.\{B}.bat for %%v in (%temp%.\{B}.bat del) do call %%v %temp%.\{?}.bat :: Change to cut-off date entered and test validity . echo. | date %1 | find "(" if not errorlevel 1 goto End Invalid date rem Create marker file dated on cut-off date> {1} date %_D% % Restore today's date % set _D= :: Create DEBUG script of sorted directory listing. echo a> %temp%.\{1} for %%v in (/) do dir /a-d/b/od/-p/z >> %temp%.\{1} for %%v in (/6) do if %%v==6 dir /a-d/b/od/-p >> %temp%.\{1} del {1} for %%v in (. .q) do echo%%v >> %temp%.\{1} echo prompt call %0 %1 %2 goto:2nd > %temp%.\{2} :: Run script debug < %temp%.\{1} | find ":" >> %temp%.\{2} echo exit>>%temp%.\{2} :: Process modified directory listing %dbgd% ctty nul %comspec%/e:2048/k < %temp%.\{2} |find ":0" | %comspec%/k %dbgd% ctty con for %%v in (%temp%.\{2}.bat del goto:End) do call %%v %temp%.\{?} :2nd - Reentry point with file names on command line. for %%v in (' '{1}) do if '%5==%%v exit at cut-off date echo %2 %5 > %temp%.\{2}.bat % Run Process on file % :End