Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8194125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:42:57+00:00 2026-06-07T04:42:57+00:00

I have a windows batch file that runs daily. Wish to log data into

  • 0

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 commands DATE and DELIMS – Cannot figure out a solution.

Is there a simple solution to create a file name that contains the day of the week i.e. 0 for monday etc.

Or do I have to resort to some better shell script.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:42:58+00:00Added an answer on June 7, 2026 at 4:42 am

    %DATE% is not your friend. Because the %DATE% environment variable (and the DATE command) returns the current date using the Windows short date format that is fully and endlessly customizable. One user may configure the system to return 07/06/2012 while another might choose Fri060712. Using %DATE% is a complete nightmare for a BAT programmer.

    There are two possible approaches to solve this problem:

    1. You may be tempted to temporarily change the short date format, by changing the locale settings in the registry value HKCU\Control Panel\International\sShortDate, to your recognizable format. Then access %DATE% to get the date in the format you want; and finally restore the format back to the original user format. Something like this

      reg copy "HKCU\Control Panel\International" "HKCU\Control Panel\International-Temp" /f >nul
      reg add "HKCU\Control Panel\International" /v sShortDate /d "ddd" /f >nul
      set DOW=%DATE%
      reg copy "HKCU\Control Panel\International-Temp" "HKCU\Control Panel\International" /f >nul
      

      but this method has two problems:

      • it tampers with a global registry value for its local particular purpouses, so it may interfere with other processes or user tasks that at the very same time query the date in short date format, including itself if run simultaneously.

      • and it returns the three letter day of the week in the local language that may be different in different systems or different users.

    2. use WMIC Win32_LocalTime, that returns the date in a convenient way to directly parse it with a FOR command.

      FOR /F "skip=1" %%A IN ('WMIC Path Win32_LocalTime Get DayOfWeek' ) DO (
        set DOW=%%A
      )
      

      this is the method I recommend.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running Windows 2003 Service Pack 2. I have a batch file that runs
I have a windows boot pen that runs a batch file when it starts
I have a Windows batch file that processes all the files in a given
I want to rename each file that ends in .log, but I have similar
I have the following line in a batch file (that runs on an old
I have an application running only on Windows and a batch file that launches
I'm working on a Windows batch file that will bcp three text files into
I have a batch file that calls a Windows GUI application. The GUI app
I have a problem changing a windows batch file into a unix shell script
I have a windows batch file that does this: for %%s in (*.sql) do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.