none
Using Robocoy with spaces in the path RRS feed

  • Question

  • Is there a way to use Robocopy to move files from one server to another when there are spaces in the path name?

    I have tried several things including this

    robocopy \\file\forms\te=reasury management\needs to be imported\ c:\scans\treasury

    There are " marks befor and after the source folder but the editor taskes them out. 

    When i put quotes on the source path Robocopy takes the entire line as the source and tells me there is no destination specified.

    Is there a way to use the quotes in Robocopy?

    Thanks for your help jrussell97

    Wednesday, September 2, 2015 3:56 PM

Answers

  • Start-Process -FilePath 'c:\robocopy'  -Arguments @('\\file\forms\te=reasury management\needs to be imported', 'c:\scans\treasury','*.*')


    \_(ツ)_/


    • Edited by jrv Wednesday, September 2, 2015 4:54 PM
    • Marked as answer by JRussell97 Thursday, September 3, 2015 8:18 PM
    Wednesday, September 2, 2015 4:54 PM
  • Start-Process is not necessary to run robocopy in PowerShell. Just type the command into the PowerShell window and press Enter, just like you do in cmd.exe. Normal command-line quoting rules apply, of course.

    This article may be helpful:

    Windows IT Pro: Running Executables in PowerShell


    -- Bill Stewart [Bill_Stewart]

    Thursday, September 3, 2015 8:31 PM
    Moderator

All replies

  • Sorry for the typo it shopuld not be te=reasury it is just treasury

    Wednesday, September 2, 2015 3:58 PM
  • There are " marks befor and after the source folder but the editor taskes them out. 


    You do need the double quotes around all paths that have embedded spaces.
    Which "editor" are you thinking of?
    Wednesday, September 2, 2015 4:28 PM
  • use notepad and Quotes around the Path notepad should not remove them.
    Wednesday, September 2, 2015 4:31 PM
  • Start-Process -FilePath 'c:\robocopy'  -Arguments @('\\file\forms\te=reasury management\needs to be imported', 'c:\scans\treasury','*.*')


    \_(ツ)_/


    • Edited by jrv Wednesday, September 2, 2015 4:54 PM
    • Marked as answer by JRussell97 Thursday, September 3, 2015 8:18 PM
    Wednesday, September 2, 2015 4:54 PM
  • I just meant when I typed it in the forum it removed the quotes. 

    I will try launching it wuth powershell to see if that makes a difference.  So far when just running it at the command prompt it has not worked.

    Thanks,

    John

    Wednesday, September 2, 2015 8:23 PM
  • When you say that something didn't work, you have to say how it didn't work. You have to copy and paste the exact command you are running and the exact error message you are getting.

    Just saying "it has not worked" conveys no useful information whatsoever, because we can't see your screen.

    To run the robocopy command, you must use normal command-line quoting rules, just like you would have to with any other command you type at a command line. Robocopy doesn't have special quoting rules.

    Also just FYI that this isn't a robocopy support forum.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, September 2, 2015 8:28 PM
    Moderator
  • Hi,

    Quotes do work in Robocopy.  Are you pasting the code in from anywhere, or actually typing it?   CMD has different font types - and some allow you to use the different types of quotes - double quote / double left quote / double right quote.  

    Only the double quote works, and that's the one that is used when typing into CMD.  Try typing your command instead of copying it if you're doing that.

    Wednesday, September 2, 2015 11:35 PM
  • I did say how it did not work.  It tells me there is no destination folder specified because it takes the wole line as one parameter.

    I did follow the normal quoting rules for CMD.

    I realise that it is not a forum for Robocopy.  I also realise that most of you use Robocopy from time to time just as I do.

    Thanks to all oof you who helped.

    Thursday, September 3, 2015 8:18 PM
  • Start-Process is not necessary to run robocopy in PowerShell. Just type the command into the PowerShell window and press Enter, just like you do in cmd.exe. Normal command-line quoting rules apply, of course.

    This article may be helpful:

    Windows IT Pro: Running Executables in PowerShell


    -- Bill Stewart [Bill_Stewart]

    Thursday, September 3, 2015 8:31 PM
    Moderator
  • Except - RoboCopy does not follow those rules because it parses the commandline in its own way. Try this:

    S C:\scripts> robocopy c:\test space c:\test *.*
    
    ------------------------------------------------------------------------------
      ROBOCOPY     ::     Robust File Copy for Windows
    ------------------------------------------------------------------------------
    
     Started : Thursday, September 3, 2015 4:40:39 PM
      Source - c:\test\
        Dest - C:\scripts\space\
    
       Files :
     Options : /DCOPY:DA /COPY:DAT /R:1000000 /W:30
    
    -----------------------------------------------------------------------------
    
    RROR : Invalid Parameter #3 : "c:\test"
    
          Simple Usage :: ROBOCOPY source destination /MIR
    
                source :: Source Directory (drive:\path or \\server\share\path).
           destination :: Destination Dir  (drive:\path or \\server\share\path).
                  /MIR :: Mirror a complete directory tree.
    
       For more usage information run ROBOCOPY /?
    
    
    ***  /MIR can DELETE files as well as copy them !
    PS C:\scripts>

    If we do this it works:
     robocopy 'c:\test space' c:\test *.*

    Using "Start-Process" eliminates the debate as it works in all circumstances with no need to consider quotes.

    Oh .. With commands that have named parameters the quotes are usually not needed.


    \_(ツ)_/

    Thursday, September 3, 2015 8:48 PM
  • Your command line:

    robocopy c:\test space c:\test *.*

    That is telling robocopy that your source directory is c:\test and your destination directory is space.

    It's expecting the third parameter (c:\test) to be a file specification, not a path, so it gives you an error.

    Robocopy doesn't know that you mean c:\test space is a directory name unless you put it in quotes. Exactly the same as any other command line command.


    -- Bill Stewart [Bill_Stewart]

    Thursday, September 3, 2015 9:14 PM
    Moderator
  • My exact point.  The following will always work and we don't need to consider spaces or quotes.

    start-process robocopy -NoNewWindow -ArgumentList @('c:\test space','c:\test','*.*')


    \_(ツ)_/

    Thursday, September 3, 2015 9:24 PM
  • To further clarify...the follwong will NOT work.

    start-process robocopy -NoNewWindow -ArgumentList 'c:\test space c:\test *.*'

    If PowerShell or .. Net Process.Start receives an array it assumes each is a single item.  Almost all command argument processors handle this correctly BUT ... not all.

    Blame it on Unix and IBM.


    \_(ツ)_/

    Thursday, September 3, 2015 9:26 PM
  • But my point was that Start-Process is not necessary. Just type the command and run it.


    -- Bill Stewart [Bill_Stewart]

    Thursday, September 3, 2015 10:01 PM
    Moderator
  • But my point was that Start-Process is not necessary. Just type the command and run it.


    -- Bill Stewart [Bill_Stewart]


    Yeah - with quotes - which is what seems to confuse everybody.

    \_(ツ)_/

    Thursday, September 3, 2015 10:21 PM