Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    5 Star Lounger
    Join Date
    May 2001
    Location
    Allen, Texas, USA
    Posts
    727
    Thanks
    1
    Thanked 0 Times in 0 Posts

    DOS copy command

    I'm trying to create a batch file for my backup program. I remembered most of my DOS stuff, but it keeps giving me a syntax error when I test it in a cmd window. I want to copy certain directories from one drive f:\ to my c:\. I need it to copy all files and directories and not ask for confirmation to overwrite.

    Shouldn't this work? What am I missing?
    xcopy f:\home\ c:\backup\ /E /V /Y

  2. #2
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,168
    Thanks
    47
    Thanked 978 Times in 908 Posts
    Robocopy is your friend.
    http://windowssecrets.com/forums/sho...lp-with-syntex

    cheers, Paul

  3. #3
    5 Star Lounger
    Join Date
    May 2001
    Location
    Allen, Texas, USA
    Posts
    727
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Looks like all I needed to do was add the quotes. Thanks!

  4. #4
    5 Star Lounger
    Join Date
    May 2001
    Location
    Allen, Texas, USA
    Posts
    727
    Thanks
    1
    Thanked 0 Times in 0 Posts
    What I'm trying to do now is get this into a batch file.
    When I run the .bat file it will open up the command prompt with the cmd, but then it just stops and doesn't start the next command of the xcopy. What am I missing?

  5. #5
    5 Star Lounger
    Join Date
    Jan 2010
    Location
    Los Angeles, CA
    Posts
    828
    Thanks
    4
    Thanked 38 Times in 34 Posts
    Could you post the contents of the bat file? The cmd should be processing one line after the other within the bat file.

  6. #6
    5 Star Lounger
    Join Date
    May 2001
    Location
    Allen, Texas, USA
    Posts
    727
    Thanks
    1
    Thanked 0 Times in 0 Posts
    cmd
    xcopy "f:\home\ken" "c:\Tropix Server Data\home\ken" /E /V /Y

  7. #7
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,413
    Thanks
    33
    Thanked 195 Times in 175 Posts
    There's no need for the first line (cmd) !
    BATcher

    Time prevents everything happening all at once...

  8. #8
    5 Star Lounger
    Join Date
    Jan 2010
    Location
    Los Angeles, CA
    Posts
    828
    Thanks
    4
    Thanked 38 Times in 34 Posts
    BATcher is correct. The first line opens a new command prompt which waits until you exit it before running the second line. Perhaps you are confused with regards to Linux/Unix script files which have a "#!" on the first line identifying the script processor to use for the file.

  9. #9
    5 Star Lounger
    Join Date
    May 2001
    Location
    Allen, Texas, USA
    Posts
    727
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks. I removed the first line and it starts OK.
    It doesn't seem to run long enough though.
    Is there a way for the prompt to stay open to display that it finished before just closing?

  10. #10
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,413
    Thanks
    33
    Thanked 195 Times in 175 Posts
    Put PAUSE as the final/second line after XCOPY
    BATcher

    Time prevents everything happening all at once...

  11. #11
    3 Star Lounger jockmullin's Avatar
    Join Date
    Dec 2009
    Location
    St-Eustache,QC,Canada
    Posts
    239
    Thanks
    10
    Thanked 21 Times in 20 Posts
    Put a line at the end that just says:
    pause

    This will cause a prompt "Hit any key to continue", and when you do so it will close.
    Then you will be able to see the command output before doing so.

    Jock

  12. #12
    5 Star Lounger
    Join Date
    May 2001
    Location
    Allen, Texas, USA
    Posts
    727
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Perfect. Thanks!

  13. #13
    5 Star Lounger
    Join Date
    May 2001
    Location
    Allen, Texas, USA
    Posts
    727
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Last questions, when running the xcopy, if a file is in use, right now the entire job aborts. Is there a way to have it continue with the rest of the files and directories? And what about a function to not copy files that have not changed?

  14. #14
    5 Star Lounger
    Join Date
    Jan 2010
    Location
    Los Angeles, CA
    Posts
    828
    Thanks
    4
    Thanked 38 Times in 34 Posts
    Run: xcopy /?
    That will print out all the options and what they do.
    I use the /A option - it copies files only when the archive bit is set, and turns the archive bit off after it copies the file. The archive bit is turned on by Windows each time the file is changed.
    The /C option continues copying after an error.

  15. #15
    3 Star Lounger jockmullin's Avatar
    Join Date
    Dec 2009
    Location
    St-Eustache,QC,Canada
    Posts
    239
    Thanks
    10
    Thanked 21 Times in 20 Posts
    Robocopy is a much better copy program for copying over networks or where busy files may be a problem - it can use restartable or backup mode with fallback on busy and has retry and include/exclude options. Also provides nice stats and does logging etc. The syntax is more or less a superset of xcopy.

    One of MS's better programs IMHOP.

    Jock

Page 1 of 2 12 LastLast

Posting Permissions

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