Batch file to create folder YYYYMMDD to backup file

I need some help...

I run a daily backup and I want the job to:

Create a folder YYYYMMDD based on today's date
Backup files to the newly created folder

I've included the my current script below which somebody else wrote.  It currently creates the date folder but as:

Sun 11_05_2008

I'm not very experienced with batch files (I didn't write this one) and I just need the modified code so the folder is created as YYYYMMDD.
@echo off
echo ===============================================================
echo Create folder and backup files
echo ===============================================================
@echo off
md "\\server\backups\%DATE:/=_%"
STSADM -o backup -directory "\\server\backups\%DATE:/=_%" -backupmethod full -overwrite 
echo completed

Open in new window

drewberryliciousAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

drewberryliciousAuthor Commented:
When I run echo %date% - the date I get (per what's currently created by the existing batch file) is Sun 11/09/2008
0
Lee W, MVPTechnology and Business Process AdvisorCommented:
@echo off
echo ===============================================================
echo Create folder and backup files
echo ===============================================================
@echo off
md "\\server\backups\%DATE:~-4%%date:~4,2%%date:~7,2%"
STSADM -o backup -directory "\\server\backups\%DATE:~-4%%date:~4,2%%date:~7,2%" -backupmethod full -overwrite
echo completed
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
omarfaridCommented:
try this

@echo off
echo ===============================================================
echo Create folder and backup files
echo ===============================================================
@echo off
md "\\server\backups\%DATE:/=_%"
STSADM -o backup -directory "\\server\backups\%date:~10,4%%date:~4,2%%date:~7,2%" -backupmethod full -overwrite
echo completed
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Lee W, MVPTechnology and Business Process AdvisorCommented:
omarfarid,

Your answer is essentially the same concept as mine... but won't work because you didn't account for the directory creation area.
0
omarfaridCommented:
Well, I concentrated on the date part and basically modified the asker's code
0
drewberryliciousAuthor Commented:
Worked like a charm.  Thanks for being so thorough (and quick)!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.