Solved

Batch file to copy directory with date stamp

Posted on 2007-03-30
3
1,748 Views
Last Modified: 2008-01-09
Windows 2000 pro and XP Pro

Need to create a batch file that will copy a directory and all contents
to a new directory with the same name plus the date.

Example:
Source directory = DATA
Destination directory = DATA_033007

I will run the batch file every night and backup my data to another drive.

Thx

0
Comment
Question by:Charles_Foote
3 Comments
 
LVL 22

Accepted Solution

by:
Christopher McKay earned 500 total points
ID: 18825506
The following script should work for you.

@ echo off
for /f "tokens=1-4 delims=/ " %%a in ('date /t') do (
  set dow=%%a
  set mm=%%b
  set dd=%%c
  set yy=%%d
)

xcopy <source> <source>%mm%%dd%%yy%



Hope this helps!

:o)

Bartender_1
0
 
LVL 2

Expert Comment

by:altra22
ID: 18825513
Open notepad and write this line
xcopy /e /v /y S:\DATA D:\Backup\DATA_033007
and save it as *.bat then make a schedule to run this file
note that drive S: Source drive and D: destination
for more info http://www.ahuka.com/backup/backup3.html
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 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