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,890 of 42,547    |
|    w_cohen@hotmail.com to All    |
|    Interrogating day-of-week variable in DO    |
|    15 Jan 14 08:21:06    |
   
   I've got the correct commands to determin the day of week in a DOS bat file   
   but am having trouble interrogating the variable in order to do some   
   additional processing in Win XP.   
   Can someone have a look and please advise.   
      
   :CHK_DOW   
   setlocal   
   for /f "delims=" %%a in ('wmic path win32_localtime get dayofweek /format:list   
   ') do for /f "delims=" %%d in ("%%a") do set %%d   
   echo day of the week : %dayofweek%   
   IF %dayofweek% > 5   
    REN O:\Input\Orders\RS\ups50ords.txt O:\Input\Orders\RS\ups51ords.txt   
    REN O:\Input\Orders\RS\ups50ords.bkp O:\Input\Orders\RS\ups50ords.txt   
   :END   
   endlocal   
      
   The 'IF %dayofweek% > 5' never seems to be executed and the rest of the file   
   commands are ignored.   
   Am I not able to interrogate the variable in the way I've shown?   
   I want to execute two rename commands when the bat routine is run on a   
   Saturday or Sunday only.   
   I can't use the endlocal until I'm finished using teh variable elsewhere in   
   the BAT file, correct?   
      
   Thanks,   
   Walter   
      
   --- 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