Batch File Question


  1. Posts : 678
    Windows 7 home premium 64 bit
       #1

    Batch File Question


    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


  2. Posts : 678
    Windows 7 home premium 64 bit
    Thread Starter
       #2

    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


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 01:49.
Find Us