Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Dec 2009
    Location
    West Midlands, UK
    Posts
    236
    Thanks
    233
    Thanked 2 Times in 2 Posts

    Backups using a bat file

    Many years ago, in the age of DOS, I used the xcopy command to do a backup of several directories. I want to do so again but I have been unsuccessful. I have Windows 7 Home with administrator rights selected. I have made a .bat file xcopy c:/test.doc x:/*.* as a test, put a copy in the root of the C drive (the main drive) to copy the file to a separate hard drive. When I double click the bat file there is a flash on the screen but nothing appears in the X drive. Am I doing something wrong or is it no longer possible. Incidentally, for folders and files with names more than eight characters long I enclosed the name in inverted comas - is that still the thing to do.

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Mike,

    Try: C:\Windows\System32\xcopy C:\test.doc x:\*.*

    Try if from a command prompt first to make sure you don't get any error messages.
    Type Command in the Search box then right click on Command Prompt in the search list and select Run as Administrator.

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. The Following User Says Thank You to RetiredGeek For This Useful Post:

    mike21 (2013-11-04)

  4. #3
    Administrator
    Join Date
    Jun 2010
    Location
    Portugal
    Posts
    12,519
    Thanks
    152
    Thanked 1,398 Times in 1,221 Posts
    Batch files work as they ever have. I think the problem may be the way you are handle fiilenames and paths. Filenames and paths have no special requirements regarding length. You are required to delimit them with double quotes, if the path or the filename includes a space.

    This is an example of a command in a batch file I use to create a copy of my Outlook file:
    Code:
    xcopy "c:\users\Rui\Documents\Outlook Files\outlook.pst" "c:\users\Rui\Documents\Outlook Files Backup\outlook.pst"  /y
    P.S.: Now I have realized that you were also using the wrong kind of slash. For paths, you need to use the backslash: \
    Rui
    -------
    R4

  5. The Following User Says Thank You to ruirib For This Useful Post:

    mike21 (2013-11-04)

  6. #4
    WS Lounge VIP mrjimphelps's Avatar
    Join Date
    Dec 2009
    Location
    USA
    Posts
    3,411
    Thanks
    447
    Thanked 406 Times in 378 Posts
    When I wanted to do an incremental backup, I used XCOPY with the following switches: XCOPY c:\testfolder\*.* /M /S

    /M would do an incremental backup -- it would backup only those files which changed since the last backup, that is, only those files which had the archive bit turned on; it then would turn off the archive bit on each file it backed up.
    /S would backup all subdirectories under the one you specified.

    You could use ATTRIB +A c:\testfolder\testfile.txt to turn on the archive bit of testfile.txt, so that it would be backed up by the above XCOPY command.

    Also, to allow you to see the results of the xcopy command, put PAUSE as the last command in your batch file. In this way, the results stay on the screen until you hit ENTER.

    Here's another option:

    Put this in your batch file:

    CMD /K XCOPY c:\testfolder\*.* /M /S

    The CMD causes the command to run at the DOS prompt, rather than running in a Windows environment.
    The /K causes the command prompt window to stay open until you close it.

    Or, the "old fashioned" way:

    CMD XCOPY c:\testfolder\*.* /M /S
    PAUSE
    Last edited by mrjimphelps; 2013-11-04 at 13:00.

  7. The Following User Says Thank You to mrjimphelps For This Useful Post:

    mike21 (2013-11-04)

  8. #5
    3 Star Lounger
    Join Date
    Dec 2009
    Location
    West Midlands, UK
    Posts
    236
    Thanks
    233
    Thanked 2 Times in 2 Posts
    It works - thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •