Solved

DOS Batch Script

Posted on 2009-05-07
3
599 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 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
User profile Size Report 3 89
batch script 3 48
WMIC Command LIne 5 56
Windows updates batch files 7 100
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
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 …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

679 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