Indianapolis computer service indiana it service and network support         L5 Solutions - Blog      // We make IT easy

    indianapolis computer service

Robocopy directories and filenames with spaces

Apr 26th, 2011 | Posted by | Filed under Indianapolis IT support

Caution – this post is for computer geeks.  All other posts are approved for general consumption.

Using robocopy makes many tasks easier with its robust switches and command line options.  One thing that is not easily determined and is not readily defined in the help or online is how to use robocopy with file names and folders that contain spaces.  After some quick trial and error I determined one way to make it work without using scripting code.

I came across this issue recently when migrating a small business server, sbs2003, to sbs2011, which as an aside is much easier than migrating to sbs2008. For example, if you have a share on a server named server01 and want to copy it to the local server from which you are working and the server share has space in the filename such as “Health Benefits,”  normally you would open a command prompt using runas administrator and then enter:

robocopy \\server01\Health Benefits\ C:\Data\HealthBenefits\ /E /R:10 /COPY:DATSOU /LOG:C:\Copy_HB_results.txt

However, this does not provide the correct input syntax for robocopy and the copy does not run.  It sees the destination incorrectly as the word immediately following the space, in this case Benefits.

To correctly enter the command to copy from a server share with a space in the path name use the following command:
robocopy /”\server01\Health Benefits\/” C:\Data\HealthBenefits\ /E /R:10 /COPY:DATSOU /LOG:C:\Copy_HB_results.txt

The syntax may not seem intuitive but does indeed perform the correct copy from the share path containing a space in the name to the local server.  You can play around with different destination syntax as well if you want to continue using spaces in the share name or path.  For an explanation of robocopy and full list of command switches you can find more details at Microsoft’s Technet entry for robocopy.

I hope this helps others as it will make it much easier, imho, than scripting for those not familiar with specific scripting syntax.  I know I’ll be using it more for sbs 2011 migrations and other server maintenance.

No comments yet.
You must be logged in to post a comment.