副本和源文件夹名称/编码

问题描述 投票:0回答:2

在Windows 8上,我试图使用robocopy复制文件夹

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

但是失败了:

-------------------------------------------------------------------------------
   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.

因此问题很明显是源文件夹名称中的字符。但是为什么robocopy无法读取该字符?

robocopy
2个回答
2
投票

使用字符集1252可在我的Windows 7计算机上使用。

chcp 1252 

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

根据Notepad ++ ,. bat文件已编码:

不带BOM的UTF-8

结果:

-------------------------------------------------------------------------------
   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

我使用Windows记事本创建bat文件。

[不幸的是,当我使用相同的编码创建新的.bat文件时,无法重新创建以上内容。 Robocopy不管编码如何都会失败,我得到的最好结果是:

-------------------------------------------------------------------------------
   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.

我必须将原始的.bat文件文本复制到新的批处理文件中,才能使其正常工作。


0
投票

如果要制作批处理命令文件并以UTF-8编码保存文件,请在批处理文件的第一行使用chcp 65001。我来自捷克共和国,有类似问题。

© www.soinside.com 2019 - 2024. All rights reserved.