robocopy and source folder name/encoding

0

On windows 8 I am trying to copy a folder using robocopy

robocopy /MIR /E /DCOPY:T /s "c:\test\xupdate can’t be deployed" "c:\test\out\"

But it fails with:

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows
-------------------------------------------------------------------------------

  Started : 9. april 2015 10:56:35
   Source : C:\test\xupdate canÈÃÍt be deployed
     Dest : C:\test\out\

    Files : *.*

  Options : *.* /S /DCOPY:T /COPY:DAT /PURGE /MIR /R:1000000 /W:30

2015/04/09 10:59:44 ERROR 2 (0x00000002) Accessing Source Directory C:\test\xupdate canÈÃÍt be deployed

The system cannot find the file specified.

So the problem is obviously the character in the source folder name. But why can't robocopy read that character?

robocopy
asked on Stack Overflow Apr 9, 2015 by u123

2 Answers

2

Using character set 1252 works on my windows 7 machine.

chcp 1252 

robocopy /MIR /E /DCOPY:T /s "c:\test\xupdate can't be deployed" "c:\test\out"

According to Notepad++ the .bat file is encoded:

UTF-8 without BOM

Result:

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows

-------------------------------------------------------------------------------

  Started : Fri Aug 28 12:35:13 2015

   Source : c:\test\xupdate can't be deployed\
     Dest : c:\test\out\

    Files : *.*

  Options : *.* /S /COPY:DAT /DCOPY:T /PURGE /MIR /R:1000000 /W:30

------------------------------------------------------------------------------

                           1    c:\test\xupdate can't be deployed\

------------------------------------------------------------------------------

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :         1         0         1         0         0         0
   Files :         1         0         1         0         0         0
   Bytes :       245         0       245         0         0         0
   Times :   0:00:00   0:00:00                       0:00:00   0:00:00

   Ended : Fri Aug 28 12:35:13 2015

I used windows notepad to create the bat file.

Unfortunately I cannot recreate the above when creating a new .bat file with the same encoding. Robocopy fails regardless of encoding, the best I get is:

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows

-------------------------------------------------------------------------------

  Started : Fri Aug 28 12:37:20 2015

   Source : c:\test\xupdate can't be deployed\
     Dest : c:\test\out\

    Files : *.*

  Options : *.* /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------

2015/08/28 12:37:20 ERROR 2 (0x00000002) Accessing Source Directory c:\test\xupd
ate can't be deployed\
The system cannot find the file specified.

I have to copy the original .bat files text into a new batch file to get it to work.

answered on Stack Overflow Aug 28, 2015 by Terence • edited Dec 15, 2015 by Terence
0

If you are making batch command file and save file with UTF-8 encoding, use chcp 65001 at first line of batch file. I'm from Czech Republic and have similiar issue.

answered on Stack Overflow Mar 6, 2020 by cursedslayer • edited Mar 6, 2020 by colidyre

User contributions licensed under CC BY-SA 3.0