Solved

DOS Batch Script

Posted on 2009-05-07
3
587 Views
Last Modified: 2012-05-06
Im trying create BAT file that will backup a drive as follows

Create Directory F:\Todays Date
Copy all files from C:\ISD to F:\Todays Date

I searched for code online but nothing is straight foward.  I know that i need the xcopy command and the Mkdir command, but i am having hard time creating Folder with todays date.
Once i get the above backup.bat file, i am going to put in the daily Task schdule to run.

Thank you
0
Comment
Question by:IsdNG
  • 2
3 Comments
 
LVL 13

Expert Comment

by:usachrisk1983
Comment Utility
Try this.  If you run xcopy /? you can see all the params you can apply, I included only /E which copies all subfiles and folders including empty ones.

@echo off

set _folder=%date:~10,4%-%date:~4,2%-%date:~7,2%

if not exist "f:\_%folder%" mkdir "f:\%_folder%"

xcopy "c:\isd" "f:\_%folder%" /e

Open in new window

0
 
LVL 13

Accepted Solution

by:
usachrisk1983 earned 250 total points
Comment Utility
Sorry, screwed up the variables :)   Resolved below.

@echo off

set _folder=%date:~10,4%-%date:~4,2%-%date:~7,2%

if not exist "f:\%_folder%" mkdir "f:\%_folder%"

xcopy "c:\isd" "f:\%_folder%" /e

Open in new window

0
 

Author Closing Comment

by:IsdNG
Comment Utility
Your Awesome, thank you very much!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

10 Experts available now in Live!

Get 1:1 Help Now