Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Funny but on Unix for me this is a snap. However, I'm on Win 2K Prof and need to dynamically create a directory with todays date. I'll need it DOS compatible so something like MMDDYYYY will work (e.g. 08272002). Any ideas. I'm clueless about VB and really don't want to install PERL just for this tiny task. However, I need the functionality for some dynamic reporting.

Paste this script into a .bat file, and that should do the trick.
:: Works on any NT machine independent of regional date settings
@ECHO off
SETLOCAL
IF [%1]==[] goto s_startECHO GETDATE.cmd
ECHO Returns the date independent of regional settings
ECHO Creates the environment variables %v_year% %v_month% %v_day%
ECHO.
ECHO SYNTAX
ECHO GETDATE
ECHO.
ECHO.
GOTO :eof:s_start
FOR /f "tokens=2-4 skip=1 delims=(-)" %%G IN ('echo.^|date') DO (
FOR /f "tokens=2 delims= " %%A IN ('date /t') DO (
SET v_first=%%G
SET v_second=%%H
SET v_third=%%I
SET v_all=%%A
)
)SET %v_first%=%v_all:~0,2%
SET %v_second%=%v_all:~3,2%
SET %v_third%=%v_all:~6,4%::ECHO Today is Year: [%yy%] Month: [%mm%] Day: [%dd%]
SET v_year=%yy%& SET v_month=%mm%& SET v_day=%dd%
SET todaysdirectory=%v_month%%v_day%%v_year%
ECHO Creating Directory %todaysdirectory%
md %todaysdirectory%

![]() |
Dial up networking
|
Win2k video driver proble...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |