[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

DOS Batch Script

Posted on 2009-05-07
3
Medium Priority
?
606 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
ID: 24332736
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 1000 total points
ID: 24332744
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
ID: 31579295
Your Awesome, thank you very much!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

834 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