Link to home
Start Free TrialLog in
Avatar of moin_deen

asked on

Batch file to create Folder & files with Weekdays Name eg: MON,TUE etc.)

i need to create a batch file that will automatically create folders or files with the names of current Month (JAN, FEB, MAR) and Weekdays (MON,TUE,WED) by automatically cheking current system date. say if today is '31 Wednesday, March 2004' it should create a folder "c:\DATA\MAR\WED" or "c:\Data\MAR\FRI.txt" and so on. so please tell me how to create that. or give the example.

iam interested in automatic backup of my data files through using batch files by windows tasksheduler.

Any one has the answer?... please i need it..
Avatar of SteveGTR
Flag of United States of America image

Try this:

@echo off


for /F "tokens=1,2 delims=/ " %%a in ('date /t') do (
 set day=%%a
 set mm=%%b

set /A mm=1%mm% - 100 + 0

if %mm%==1 set month=Jan
if %mm%==2 set month=Feb
if %mm%==3 set month=Mar
if %mm%==4 set month=Apr
if %mm%==5 set month=May
if %mm%==6 set month=Jun
if %mm%==7 set month=Jul
if %mm%==8 set month=Aug
if %mm%==9 set month=Sep
if %mm%==10 set month=Oct
if %mm%==11 set month=Nov
if %mm%==12 set month=Dec

if not exist c:\data\%month%\%day:~0,3%\nul mkdir c:\data\%month%\%day:~0,3%

Good Luck,
Try my utility DateSet - you simply invoke it at the top of your BAT file and after that line you will have easy access to these variables within your BAT file:

DATE (example value - 10242002)
DAY (example value - 24)
DAYWORD (example value - Thu)
MONTH (example value - 10)
SHORTYEAR (example value - 02)
YEAR (example value - 2002)
HOURS (example value - 11)
MINS (example value - 03)
SECS (example value - 39)
AMPM (example value - AM)

DateSet is available here - click "Downloads" at the left.
Avatar of ico2

once you have done that (assuming the data is set to the envioroment variables year month day use this code.

mkdir %year%
cd %year%
mkdir %month%
cd %month%
mkdir %day%
cd %day%

when run on the next day it will produce a couple of messages (directory already exists) but will run just fine.
Avatar of moin_deen



Thank you for your prompt response.

I have tried all the batch Codes that were posted to my question. i could not get the result, Syntex error appear when ever i tried to execute the batch file. i don't have much programming techiniques, also iam new to batch file programming,

Please Give me a working EXAMPLE of batch file.

Thank You
What's your operating system version?
Hi Steve

The operating system currently installed in my system is.

Windows 98 Second Edition [Version 4.10.2222]

When you type date and the command line how does the current date display. Include the weekday if present.
if i type DATE at the command propmt this is the result.

Current date is Wed 05-05-2004

I'm sorry, but I can't tell the format with todays date. What does the format say in the next line of the date command? Something like Enter the new date: (mm-dd-yy).
Current date is Wed 05-05-2004
Enter new date (mm-dd-yy):
Avatar of SteveGTR
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi  Steave,

Your code indeed worked great. I really Thank you for posting a best solution  to my question.