Avatar of moin_deen
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..
Microsoft DOS

Avatar of undefined
Last Comment
moin_deen

8/22/2022 - Mon
SteveGTR

Try this:

@echo off

setlocal

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,
Steve
pauldoherty

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.

http://powerusers.info
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.
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER
moin_deen

Hi.

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
regards
Moindeen
SteveGTR

What's your operating system version?
ASKER
moin_deen

Hi Steve

The operating system currently installed in my system is.

Windows 98 Second Edition [Version 4.10.2222]

regards
Moindeen
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SteveGTR

When you type date and the command line how does the current date display. Include the weekday if present.
ASKER
moin_deen

if i type DATE at the command propmt this is the result.

C:\>date
Current date is Wed 05-05-2004

SteveGTR

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).
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER
moin_deen

C:\>date
Current date is Wed 05-05-2004
Enter new date (mm-dd-yy):
ASKER CERTIFIED SOLUTION
SteveGTR

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
moin_deen

Hi  Steave,

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

regards
Moindeen