Using Robocoy with spaces in the path

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

September 2nd, 2015 11:58am

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

Free Windows Admin Tool Kit Click here and download it now
September 2nd, 2015 11:59am

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?
September 2nd, 2015 12:29pm

use notepad and Quotes around the Path notepad should not remove them.
Free Windows Admin Tool Kit Click here and download it now
September 2nd, 2015 12:32pm

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

September 2nd, 2015 12:55pm

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

Free Windows Admin Tool Kit Click here and download it now
September 2nd, 2015 4:24pm

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.

September 2nd, 2015 4:29pm

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.

Free Windows Admin Tool Kit Click here and download it now
September 2nd, 2015 7:36pm

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.

September 3rd, 2015 4:19pm

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

Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 4:32pm

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.

September 3rd, 2015 4:49pm

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.

Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 5:15pm

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','*.*')

September 3rd, 2015 5:25pm

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.

Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 5:27pm

But my point was that Start-Process is not necessary. Just type the command and run it.

September 3rd, 2015 6:02pm

But my point was that Start-Process is not necessary. Just type the command and run it.

Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 6:22pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics