Link to home
Start Free TrialLog in
Avatar of IsdNG
IsdNG

asked on

DOS Batch Script

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
Avatar of usachrisk1983
usachrisk1983
Flag of United States of America image

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

ASKER CERTIFIED SOLUTION
Avatar of usachrisk1983
usachrisk1983
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IsdNG
IsdNG

ASKER

Your Awesome, thank you very much!