Windows batch: Unicode parameters for (robo) copy command

前端 未结 3 873
傲寒
傲寒 2021-01-17 18:57

I need to copy multiple files in a single batch file. The files have Unicode names that map to different codepages.

Example:

set Ara         


        
3条回答
  •  情歌与酒
    2021-01-17 19:27

    I want to create a batch file (e.g. RunThis.bat) which creates directories of names that can be Russians or others.

    Example:
    When DOS Windows is open with prompt:

    D:\>md "Russia - Шпионка"
    

    This work in command like and the name appear correctly.

    But if I try that using Notepad and save in ANSII, I can’t.
    So if I use again Notepad and save in UTF-8, it will work but with garbage characters.

    RunThis.bat (Notepad save UTF-8), give garbage characters.

    chcp 65001
    set fn14="Russia - Шпионка"
    md %fn14%
    

    The problem with notepad it uses UTF-8 with BOM.

    To save the .bat using UTF-8 without BOM we must use editor like Notepad++.

    RunThis.bat (Notepad++ save UTF-8 – no BOM)

    chcp 65001
    set fn14="Russia - Шпионка"
    md %fn14%
    

    This time its work perfectly when we run “RunThis.bat” directly from explorer.exe

提交回复
热议问题