home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch      Fun with MS-DOS batch files      42,547 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 40,552 of 42,547   
   foxidrive to Fairfax   
   Re: Changing date output format to yyyy.   
   07 Nov 12 16:34:58   
   
   From: not@this.address.invalid   
      
   On 07/11/2012 16:24, Fairfax wrote:   
      
   >>>> How can I change the %DATE% above so that it works to give me   
   >>>> yyyy.mm.dd.ddd?   
   >>>   
   >> :: date time using WMIC   
   >> :: XP Pro and higher   
   >> @echo off   
   >> for /f "delims=" %%a in ('Wmic Path Win32_LocalTime Get /value ^|Find "="')   
   do (   
   >> for /f "tokens=1,* delims==" %%b in ('cmd /c echo %%a') do set "%%b=00%%c")   
   >>   
   >> set DayOfWeek=%DayOfWeek:~2%   
   >> set Quarter=%Quarter:~2%   
   >> set WeekInMonth=%WeekInMonth:~2%   
   >> set Day=%Day:~-2%   
   >> set Hour=%Hour:~-2%   
   >> set Minute=%Minute:~-2%   
   >> set Month=%Month:~-2%   
   >> set Second=%Second:~-2%   
   >> set Yr=%Year:~4%   
   >> set Year=%Year:~2%   
   >>   
   >> if %dayofweek%==1 set ddd=Mon   
   >> if %dayofweek%==2 set ddd=Tue   
   >> if %dayofweek%==3 set ddd=Wed   
   >> if %dayofweek%==4 set ddd=Thu   
   >> if %dayofweek%==5 set ddd=Fri   
   >> if %dayofweek%==6 set ddd=Sat   
   >> if %dayofweek%==7 set ddd=Sun   
   >>   
   >> set stamp=%year%-%month%-%day%-%ddd%_%hour%-%minute%-%second%   
   >>   
   >> echo %%stamp%% is set to %stamp% (yyyy-mm-dd-ddd_hh-mm-ss)   
      
   > Darn, was hoping it would be more straightforward.  I'm only a power   
   > user and have never found batch file scripting easy, unlike other   
   > scripting languages, I'll try to see how to incorporate all this   
   > massive code into my copy bat string as posted above.   
      
   Firstly, as your machine is locked down the admin might also have locked wmic   
   and WSH.   
   Can you run the batch file above and get a meaningful stamp in the last line?   
      
   If so then you can use this as the last line, and replace %date% with %stamp%   
   in your code (which you can   
   add following this line).   
      
      
   set stamp=%year%.%month%.%day%.%ddd%   
      
      
      
      
      
   --   
   foxi   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca