From: SpamNot@NoJunkMail.org   
      
   On Tue, 06 Nov 2012 23:03:33 +1100, foxidrive   
    wrote:   
      
   >On 06/11/2012 22:18, foxidrive wrote:   
   >> On 06/11/2012 22:06, Fairfax wrote:   
   >>> Good Morning!   
   >>>   
   >>> I have a batch file that works very well in creating a backup copy:   
   >>>   
   >>> copy "F:\TIMER-WORK\Time Worked Calculator\APP- TWCalc\twc.ses"   
   >>> "F:\TIMER-WORK\Time Worked Calculator\APP- TWCalc\zBKP- twc.ses -   
   >>> %DATE%., %TIME:~0,2%h%TIME:~3,2%m%TIME:~6,2%s.ses"   
   >>>   
   >>> Because my regional settings at home work, I get the correct output of   
   >>> part of the date, in yyyy.mm.dd.(day missing).   
   >>>   
   >>> At work (also with WinXP), I edit the regional settings but they don't   
   >>> stick.   
   >>>   
   >>> How can I change the %DATE% above so that it works to give me   
   >>> yyyy.mm.dd.ddd?   
   >>   
   >> Here is a non-region dependent way of getting a time stamp using Wmic.   
   >   
   >I note now that you want the day too. Try this:   
   >   
   >   
   >:: 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)   
   >   
   >pause   
      
   Hey, thanks!   
      
   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. I might   
   have to live with my simple code above and keep manually correcting   
   date display in input, I foresee .   
      
    Sometimes, wish I could just inject, or whatever, the   
   scripting gene as unlike other things, scripting doesn't come easy to   
   me in some languages (like batch and vbs!).   
      
   Cheers.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|