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,714 of 42,547    |
|    foxidrive to pyotr filipivich    |
|    Re: Copy option    |
|    05 Aug 13 15:42:40    |
   
   From: not@this.address.invalid   
      
   On 5/08/2013 15:24, pyotr filipivich wrote:   
   > Here's the piece of code to get a "legal" time and date stamp for   
   > including in a name:   
   >   
   > echo off   
   > for /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set weekday=%%a&   
   > set month=%%b& set day=%%c& set year=%%d)   
   > for /f %%a in ('time /t') do set time=%%a   
   > for /f "tokens=1-3 delims=: " %%a in ('time /t') do (set hours=%%a&   
   > set minutes=%%b& set TheEnd=%%c)   
   > set TimeHack=%month%%day%%hours%%minutes%   
   > echo TimeHack is %timehack%   
   > pause   
   >   
   > I use this a lot to timestamp logfiles with the following code   
   > Set LogFile=Log%TimeHack%.rtf   
   > >>echo %logfile% [message goes here]   
   >   
      
   It is still region sensitive and people reading here are from all over the   
   world.   
      
   For a robust and region insensitive method, see this. XP Pro and higher.   
      
   @echo off   
   for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set   
   "dt=%%a"   
   set "YYYY=%dt:~0,4%"   
   set "MM=%dt:~4,2%"   
   set "DD=%dt:~6,2%"   
   set "HH=%dt:~8,2%"   
   set "Min=%dt:~10,2%"   
   set "Sec=%dt:~12,2%"   
      
   set datestamp=%YYYY%%MM%%DD%   
   set timestamp=%HH%%Min%%Sec%   
   set fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%   
   echo datestamp: "%datestamp%"   
   echo timestamp: "%timestamp%"   
   echo fullstamp: "%fullstamp%"   
   pause   
      
      
      
   --   
   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