Setting a windows batch file variable to the day of the week

后端 未结 17 1960
南方客
南方客 2020-11-27 20:14

I have a windows batch file that runs daily. Wish to log data into a file and want to rotate it (i.e. having at most the last 7 days worth of data).

Looked into the

17条回答
  •  再見小時候
    2020-11-27 20:35

    This is not my work (well, I modified it slightly from the example), and it's late to the game, but this works on Server 2003 for me;

    @echo off  
    set daysofweek=Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday  
    for /F "skip=2 tokens=2-4 delims=," %%A in ('WMIC Path Win32_LocalTime Get DayOfWeek /Format:csv') do set daynumber=%%A  
    for /F "tokens=%daynumber% delims=," %%B in ("%daysofweek%") do set day=%%B
    

    Citation: TechSupportForum

提交回复
热议问题