Windows batch: Unicode parameters for (robo) copy command -
i need copy multiple files in single batch file. files have unicode names map different codepages.
example:
set arabicfile=ڊڌڵڲڛشس set cyrillicfile=щЖЛдЉи set germanfile=bücher copy %arabicfile% someplaceelse copy %cyrillicfile% someplaceelse copy %germanfile% someplaceelse
problem: batch files cannot unicode.
question: how can write unicode file names batch file copy command recognizes them?
notes:
i not care how file names displayed.
batch file more copy these files, simplified description make problem clearer.
correct batch file:
with arnout's answer modified batch file follows. works correctly without requiring font change (which messy, arnout commented).
@echo off chcp 65001 set arabicfolder=ڊڌڵڲڛشس set cyrillicfolder=щЖЛдЉи set germanfolder=bücher robocopy /e d:\temp\test\%arabicfolder% d:\temp\test2\%arabicfolder% /log:copy.log robocopy /e d:\temp\test\%cyrillicfolder% d:\temp\test2\%cyrillicfolder% /log+:copy.log robocopy /e d:\temp\test\%germanfolder% d:\temp\test2\%germanfolder% /log+:copy.log
if
- i add
chcp 65001
first line of batch file, - save file utf-8 without bom, and
- set console font else "raster fonts" (on win7 box can choose consolas or lucida console),
it works. simple, no? :-)
(the font change not necessary, provided you're not writing non-ascii output console.)
Comments
Post a Comment