none
space in directory name in robocopy RRS feed

  • Question

  • How do I deal with a space in a directory name in Robocopy?

    e.g.   Copy all files from C:\My Directory to E:\My Directory

    Robocopy C:\"My Directory" E:\"My Directory" *.* doesn't work

    Thanks

    Wednesday, June 12, 2013 5:20 AM

Answers

  • Try following

    robocopy "C:\My Directory" "D:\My Directory" *.*


    Regards, Santosh

    I do not represent the organisation I work for, all the opinions expressed here, are my own.

    This posting is provided AS IS with no warranties or guarantees and confers no rights.

    Blog | Wiki

    Wednesday, June 12, 2013 5:40 AM
    Moderator
  • Santosh's way of using quotes is correct. The default choice of files with Robocopy is *.* so you don't have to specify that. Just use this:

    robocopy "c:\my directory" "e:\my directory"

    Wednesday, June 12, 2013 5:53 AM

All replies

  • Try following

    robocopy "C:\My Directory" "D:\My Directory" *.*


    Regards, Santosh

    I do not represent the organisation I work for, all the opinions expressed here, are my own.

    This posting is provided AS IS with no warranties or guarantees and confers no rights.

    Blog | Wiki

    Wednesday, June 12, 2013 5:40 AM
    Moderator
  • Santosh's way of using quotes is correct. The default choice of files with Robocopy is *.* so you don't have to specify that. Just use this:

    robocopy "c:\my directory" "e:\my directory"

    Wednesday, June 12, 2013 5:53 AM
  • Works.   Thanks Santosh.
    Wednesday, June 12, 2013 5:55 AM
  • Works.   Thanks Santosh.
    You are welcome :-)

    Regards, Santosh

    I do not represent the organisation I work for, all the opinions expressed here, are my own.

    This posting is provided AS IS with no warranties or guarantees and confers no rights.

    Blog | Wiki

    Wednesday, June 12, 2013 6:01 AM
    Moderator
  • When the directory has spaces in it, you must enclose it in quotes.

    However, unlike a directory with no spaces, you must also drop the \ as in the example below.

    robocopy M:\MY-MUSIC\ D:\MY-MUSIC\ /MIR

    robocopy M:\MY-MUSIC "D:\MY MUSIC" /MIR

    Monday, December 1, 2014 8:23 PM
  • It is also possible to add a space between the \ and the ", as in 
    robocopy "C:\My Directory\ " "D:\My Directory\ " /MIR

    I stumbled into this thread trying to figure out why simply changing an existing line broke when I added a space-name and quotes, and this was the answer, but I didn't read your last comment correctly (since it changed the example, and I thought the important part was the - distinguishing when quotes were needed) until after I'd experimented and found that to work. 
    • Edited by G. Mitchell Monday, December 8, 2014 8:16 PM removed the superfluous *.* for a more meaningful command, after I copy/paste/edited the original example given from another post.
    Monday, December 8, 2014 8:15 PM
  • It is also possible to add a space between the \ and the ", as in 
    robocopy "C:\My Directory\ " "D:\My Directory\ " /MIR

    Thanks for the tip, adding a space at the end helped!


    Mahesh

    Thursday, May 4, 2017 4:40 PM
  • Actually, you should add parameters "/sec /secfix" for maintain permission, also "/e" to include subdirectories or empty ones
    Thursday, July 20, 2017 8:09 AM
  • Thanks for the post.... I have used robocopy in the past, but was having issues with the source and destination BOTH having a space in the path.

    I had both source and destination wrapped in quotes, then tried one with single and the other with double, but the issue was i needed to drop the \ at the end....

    example of working command

    "C:\users\john\desktop\new folder" C:\temp\new folder"

    example of failing command

    "C:\users\john\desktop\new folder\" C:\temp\new folder"

    Thanks again for the TIP

    Wednesday, November 8, 2017 5:06 PM