Solved Batch File Question

boweasel

New member
Power User
Local time
9:03 AM
Messages
678
I am incredibly ignorant about batch files, yet I'd like to create one to do weekly backups of my documents. The following .bat file more or less works, but it needs tweaking.

xcopy /e /y /c /s /i c:\users\scott\documents h:\Backup

The H: drive is a large external drive. The above file does work, but it seems to simply overwrite the folder on the H drive, and I want it to keep the weekly backups until I manually delete them. I thought the /I switch would cause it to create new versions (Backup (1), Backup (2), etc), but that seems not to work. Ideally there would be code that would append the current date to the file called Backup, but I can't seem to find any workable method for doing that.
 

My Computer

Computer type
Laptop
OS
Windows 7 home premium 64 bit
CPU
AMD K10
Motherboard
Hewlett-Packard 1444 (Socket S1G4)
Memory
3.00GB Dual-Channel DDR3 @ 532MHz
Graphics Card(s)
ATI AMD M880G with ATI Mobility Radeon HD 4250 (HP)
Sound Card
Realtek
Screen Resolution
1366 x 768
Hard Drives
465GB Western Digital
Antivirus
MSE
After a lot of trial and error I got the following to do pretty much what I want:
@echo off
set curr_date=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%
mkdir G:\"%curr_date%_backup"
xcopy "%USERPROFILE%\Documents" h:\"%curr_date%_backup" /D/S/H/V/C/F/K/Y
 

My Computer

Computer type
Laptop
OS
Windows 7 home premium 64 bit
CPU
AMD K10
Motherboard
Hewlett-Packard 1444 (Socket S1G4)
Memory
3.00GB Dual-Channel DDR3 @ 532MHz
Graphics Card(s)
ATI AMD M880G with ATI Mobility Radeon HD 4250 (HP)
Sound Card
Realtek
Screen Resolution
1366 x 768
Hard Drives
465GB Western Digital
Antivirus
MSE
Back
Top