Solved

DOS Batch Script

Posted on 2009-05-07
3
603 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 250 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

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

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

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…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 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