Create dir with current date then xcopy to it

Microsoft Windows xp professional editio...
September 24, 2009 at 07:39:39
Specs: Windows XP
I need to create a script (.bat file) that will first create a folder named the current date. Then I need it to copy a bunch of files and folder structure there. It is for a routine archive of some files from one location to another. I have both pieces but don't know how to put them together. Here is what I have.

Create Directory with current date
@echo off
for /F "tokens=2-4 delims=/- " %%A in ('date/T') do md %%A%%B%%C

Copy files and directory structure
xcopy "C:\Archive Test\Copy From" "C:\Archive Test\Copy To\" /S /E /-Y

Thanks in advance for your help!

See More: Create dir with current date then xcopy to it

Report •

September 25, 2009 at 00:19:55
Without getting bogged down in longish directory names, xcopy will create the destination for you.

xcopy src dest\

Helping others achieve escape felicity


Report •

September 25, 2009 at 03:35:47
Set parent folder in the target folder diferent of source folder to evoid cyclic copying:
source c:\archive test\...
target c:\archive test2\...

@echo off
setlocal enabledelayedexpansion
for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set target=c:\archive test2\%%A%%B%%C
xcopy "C:\archive test\*" "%target%\" /E /-Y


I sugest you to set target folder name to format YEAR\MONTH\DAY, in another manner the top-down list of backup folders will seem visually confused, not displayed in a chronological sequence.

Report •

Related Solutions

Ask Question