1

On my Windows 10 machine I am trying to run a "robocopy" command (from a .bat file) to backup files.

Everything is fine as long as the paths (to folders to backup) do not contain letters like ö, ü, ä which whoever is inevitable as this is a German environment.

Earlier I was able to fix this by sending a

chcp 1252

command first, so that the command prompt window runs on Code Page 1252 which has these characters. But this was on a Windows 7 machine then. (The default code page on this system is 850. It is a larger institutional network, and I have no administrator access.)

Now with the Windows 10 machine this does not have effect for me. The code page is set to 1252 (at least that's the return when you ask "chcp"), and still the robocopy command does not run.

Here is my robocopy command:

robocopy C:\Users\Myself\Documents\Notizbücher Y:\RobocopyBackups\001_NotizbücherBackup /e /mir /np /z /tee /log:Y:\RobocopyBackups\001_Backup_log.txt

When I run this, the "ü" in "Notizbücher" always gets messed up, and of course the command cannot be run since the computer does not find the (messed up) address.

I tried all sorts of things

  • Sending first chcp 1252

  • Making sure that my .bat file where I keep the code is encoded as Windows-1252 (I am using Notepad++)

  • Trying chcp 65001 for UTF-8 (with and without encoding the .bat file similarly)

  • Trying chcp 2851 for ISO-8859-1, just for fun...

It's always the same: the "ü" gets messed up.

Of course I could just remove the "ü" from the folder names. But I want to have a clean solution, not such a lame workaround.

What could I do?

  • This is not really programming related and may be more suited on superuser. Also it shouldn't be related to chcp, but to the file system of Y. What is Y? – JeffRSon Oct 30 '19 at 10:45
  • @JeffRSon Yes, I know, it is somewhat at the limits of programming... Y: is simply a drive of that name, like C: That's not the issue here, my other robocopy commands work fine with it and store loads of data on it. It is really an issue with the u-Umlaut (oder oder Umlauts). – Christian Geiselmann Oct 30 '19 at 13:39
  • PS: I think it should be code page related, as I had the same problem 2 years ago on a Windows 7 machine, and at that time I could solve it using chcp 1252. The puzzling thing is that it does not work now. And the only thing I know is different is the leap from Win7 to Win10. – Christian Geiselmann Oct 30 '19 at 13:42
  • Which file system is Y? Try to copy to C - what happens to the umlauts? CodePage is for console (Input, mostly Output) - not related to file systems. – JeffRSon Oct 30 '19 at 18:11
  • Oh - and try robocopy from commandline, not batch. Any difference? – JeffRSon Oct 30 '19 at 18:13
  • @JeffRSon Y is a totally ordinary drive in our (local government) institution where we store our everday stuff like word files, excel files, pdfs... so it should not be different from C: I suppose (what's that today? NTFS?) - As for running it from command line: I tried this in so far as I indeed tried what happens when I copy-paste my command from the .bat file (instead of running the .bat). I was too lazy to type the lengthy thing letter by letter. Does this make a difference? – Christian Geiselmann Oct 30 '19 at 18:58
  • PS: New experiment done now. I can TYPE address like Y:/bücher , and it accepts it without distoring it. (I used a phantasy file name, so I did not copy anything, but the problem with recognizing the ü does not exist.) - So would the problem be somewher ein the encoding of the .bat file? But I tried changing this as well (see my initial question), using Notepad++ as editor and using its "Encoding" options from the menu. – Christian Geiselmann Oct 30 '19 at 19:08
  • Hard to tell. I probably would try to save the BAT/CMD as UTF8 with BOM. No chcp. – JeffRSon Oct 30 '19 at 19:14
  • New tests: Saved the .bat file with encoding UTF8 with BOM. Run it (without chcp 1252 command in the batch). Result: same issue with the ü. - Run it again, now with the chcp 1252 command in the batch. Result: same issue. - Just the characters that replace the ü a different between these tests. Meaning: The chcp 1252 command has some effect, although not the desired one. – Christian Geiselmann Oct 31 '19 at 11:29

1 Answers1

1

Solution found after doing all sorts of experiments (not least with inspiration through commenter JeffRSon):

Consideration

As the code page used by default on the system is Code Page 850 (part of the "OEM" series of code pages), I thought I could give it a try and save my .bat file with exactly that encoding.

Implementation

As I am using Notepad++ for writing, I used Notepad++'s "Encode" option in the menu, i.e. I selected there

[Menu] -> Encode --> Character sets --> Western European --> OEM 850

(And of course I also removed the chcp 1252 command from the batch.)

I did not forget to save this file afterwards.

Result

Surprise or not, the system now accepts my batch commands and executes them nicely.

Note for newbees (like me)

For finding out what the current (default) code page of your system is, enter

chcp

into your command prompt. It should then return the current value, in my case: 850.

Community
  • 1
  • 1