How to generate a file name with the day in it from a batch file

Posted on 2006-04-28
Last Modified: 2010-04-17
I can make a file with the date and time in it, but I need the DAY in the name.

This is what works to generate the full date: %date:~4,2%_%date:~7,2%_%date:~10,4%
How do I get a day name in the filename?

Example: systembackup_monday.bkf, systembackup_tuesday.txt

I appreciate the help!
Question by:jptechnical
    LVL 24

    Accepted Solution

    Try this (only tested in w2k)

    set dayname=%date:~0,3%
    if %dayname%==Mon set daynamefull=Monday
    if %dayname%==Tue set daynamefull=Tuesday
    if %dayname%==Wed set daynamefull=Wednesday
    if %dayname%==Thu set daynamefull=Thursday
    if %dayname%==Fri set daynamefull=Friday
    if %dayname%==Sat set daynamefull=Saturday
    if %dayname%==Sun set daynamefull=Sunday
    echo %daynamefull%
    LVL 1

    Author Comment

    Excellent! That is exactly what I needed. For the life of me I couldn't find the ~0,3 part. I am sure I wasn't looking in the keywords.

    You get the points anyway, but can you post a like to a reference you might have used or a list of the variables?


    As it turns out, the abbreviated form will be fine, I didnt' realize the default output was not a full name.

    You da man!

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    squareUp  challenge 22 81
    How to split this in C++ 4 52
    Fibonacci challenge 11 62
    strCount chalenge 3 36
    A short article about problems I had with the new location API and permissions in Marshmallow
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now