:: UniDateC.bat - A way to parse and store today's date into the environment. :: :: Tom lavedas :: http://www.pressroom.com/~tglbatch @%4 echo %dbgu% off if '%1'=='' %0 Date > {A} % Default 'object' name % :: Setup to get current date into temporary file echo @prompt if '%%%%2==' %%%%0=$D$_echo %%%%2y$g{C}.bat$_> {A}.bat %comspec% /e:2048 /c {A}.bat > {B}.bat :: Put date into temp file {C}.bat for %%v in (call del) do %%v {B}.bat :: Test for order of MM & DD echo. | date | find "(mm" > nul if errorlevel 1 %0 %1.DD %1.MM %1.YYYY goto:1st %0 %1.MM %1.DD %1.YYYY goto:1st :1st - Reentry with Date.MM & Date.DD in proper order on command line :: Setup for date parsing set _T= for %%v in (0 1 2 3 4 5 6 7 8 9) do set (Y/N)?%%v=%%v for %%v in (/ // -) do set (Y/N)?%%v=; echo if %%2"==(Y/N)?y" exit > {A}.bat >>{A}.bat echo %%"%%>>%%"%%{B}.bat echo set _T=%%%%_T%%%%%%%%%%2%%%% :: This peculiar line of code parses date del {A} /p < {C}.bat | %comspec% /e:2048 /k > nul :: Reassembles the date characters into variables for %%v in ({B}.bat del) do call %%v {?}.bat %0 %1 %2 %3 goto:2nd %_T% :2nd - Reentry to complete process and store result into var's set %1=%5 set %2=%6 set %3=%7 for %%v in (0 1 2 3 4 5 6 7 8 9 / // -) do set (Y/N)?%%v= set _T= :End