Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I tried to get robocopy in Windows 7 to generate a Unicode log, since I have files with Unicode characters. The command I used:

robocopy C:\mysource D:\mydest /mir /unilog:backup.log /tee

File the copy works and the onscreen output is correct, the log file itself just contains gibberish. This is regardless of whether I use the Command Prompt or the Powershell.

What gives? Am I doing something wrong?

share|improve this question
This is also my experience. Did you find a solution? – André Caron Jun 3 '12 at 16:49

3 Answers

It appears to be a bug in the XP27 version of RoboCopy (which comes with Windows 7). In version XP26 (which comes with Windows Vista) /UNILOG produces a perfectly readable Unicode log file for me. If you don't have a copy of Vista laying around EasyRoboCopy also comes with the XP26 version. (I haven't actually tried EasyRoboCopy itself, just extracted robocopy.exe out of its setup file using WinRAR.)

share|improve this answer

In your case, the command in Powershell goes something like this:

robocopy C:\mysource D:\mydest /mir | Out-File backup.log

The workaround is that you use Out-File instead of built-in /unilog parameter. You will get exactly the same log file, but now it will be properly written in unicode.

share|improve this answer
Sure it will be unicode, but there will be no special unicode characters. It's just ASCII output translated to unicode. – davor Apr 28 at 7:17

I'm not very familiar with Windows, but, at a glance, I'd say the file written by Robocopy while using the /UNILOG and /TEE switches contains a UTF-16 little-endian byte order mark followed by an ISO-8859-1 terminal typescript.

To make it readable, I did the following:

  1. Strip the byte order mark.
  2. Convert to UTF-8.
  3. Interpret and then filter out terminal control characters.

by running this command in Ubuntu:

dd if=robocopy.log ibs=1 skip=2 obs=512 \
  | iconv --from-code ISO-8859-1 --to-code UTF-8 \
  | col -b \
  > robocopy_utf-8.log

The resulting file matches what I saw in the Windows command prompt.

share|improve this answer
Any way to do similar conversion in windows? I have tried this conversion in pipe in PowerShell, but with no success:([System.Text.Encoding]::Unicode).GetString([System.Text.Encoding]::Con‌​vert([System.Text.Encoding]::GetEncoding(28591), [System.Text.Encoding]::Unicode, ([System.Text.Encoding]::GetEncoding(28591)).GetBytes($_))) – davor Apr 28 at 8:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.