Windows package: Unicode options for (robo) copy command

I need to copy multiple files into one batch file. Files have Unicode names that map to different code pages.

Example:

set ArabicFile=ڊڌڵڲڛشس set CyrillicFile=Љ set GermanFile=Bücher copy %ArabicFile% SomePlaceElse copy %CyrillicFile% SomePlaceElse copy %GermanFile% SomePlaceElse 

Problem: Batch files cannot be Unicode.

Question: How do I write Unicode file names to a batch file so that the copy command recognizes them?

Notes:

I don't care how the file names are displayed.
In fact, the batch file does much more than just copy these files, I just simplified the description to make the problem more clear.

The correct batch file:

With Arnout's answer, I changed my batch file as follows. Now it works correctly, without requiring a font change (which would be random, as Arnout commented).

 @echo off chcp 65001 set ArabicFolder=ڊڌڵڲڛشس set CyrillicFolder=Љ set GermanFolder=Bücher robocopy /ed:\temp\test\%ArabicFolder% d:\temp\test2\%ArabicFolder% /log:copy.log robocopy /ed:\temp\test\%CyrillicFolder% d:\temp\test2\%CyrillicFolder% /log+:copy.log robocopy /ed:\temp\test\%GermanFolder% d:\temp\test2\%GermanFolder% /log+:copy.log 
+7
windows filenames unicode batch-file
source share
3 answers

If a

  • I add CHCP 65001 as the first line of your batch file,
  • save the file as UTF-8 without specification and
  • set my console font to something other than "Raster fonts" (on my Win7 box I can choose Consolas or Lucida Console),

it works. Simply no?: -)

(Changing the font is actually optional if you are not writing ASCII output to the console.)

+12
source share

I'm not sure, but I think the short (8.3) file name will be ASCII, so can you reference it that way? You can find out the short file name with dir /X

+1
source share

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

Example:
When DOS Windows opens with a hint:

 D:\>md "Russia - " 

This work on the command line and the name is displayed correctly.

But if I try to use Notepad and save in ANSII , I cannot. Therefore, if I use Notepad again and save it in UTF-8, it will work, but with garbage characters.

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

 chcp 65001 set fn14="Russia - " md %fn14% 

Notebook problem uses UTF-8 with specification.

To save bytes using the UTF-8 specification without , we must use an editor, such as Notepad ++.

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

 chcp 65001 set fn14="Russia - " md %fn14% 

This time its work is excellent when we run " RunThis.bat " directly from explorer.exe

0
source share

All Articles