# Batch file backup



## IchBin (Jul 22, 2005)

Here's what I'd like to do:
I want to copy some log files to a directory each day that is named with the date. So I guess what needs to happen is that each time I run the batch file, it creates a folder with the name of the current date, then copy my log files to that folder. I'm not that great with DOS yet so I'm hoping someone can tell me how to tell it to copy to the folder with the date. I hope I'm clear enough in what I'm trying to do.

Here's what I'm working with so far.

mkdir c:\backup\%date:~4,2%-%date:~7,2%-%date:~10,4%
copy "c:\Program Files\onsite\logs\*.log" c:\datefolder here? Not sure how to tell it what the date is. lol


----------



## DaveBurnett (Nov 11, 2002)

Hint: Assign the date to an environment variable first, then use that.
You can look up how to do that as well as I can.


----------



## R0B0 (Sep 4, 2005)

Here's what I came up with working from your start:

mkdir d:\backup\%date:~4,2%-%date:~7,2%-%date:~10,4%
XXcopy "c:\Data\*.*" d:\backup\%date:~4,2%-%date:~7,2%-%date:~10,4% /S /CLONE /YY

Note, I'm using XXCopy as opposed to copy or xcopy as it has a lot more functionality, including logging.

This works very well under XP. 

Hope this helps.


----------

