Search code examples
windowsencodingsetcharacter

In Windows 10 how do I rename a file to a filename that includes a character with an umlaut?


I'm on Win10 and I have a .bat file to rename a bunch of files. Some of the entries need to be renamed to a non-English name, e.g.

RENAME "MyFile1.txt" "Eisenhüttenstadt.txt"

However, when I run this, the 'ü' comes out as something else, other characters with an umlaut also are replaced by different characters.

I've tried saving the .bat file in Notepad with Unicode and UTF-8 encoding but then Windows doesn't recognise the command when I try to run it.

I've read this and other similar issues but not found a solution, surely it's simple when you know how?

Any suggestions?


Solution

  • The default code page in the console is 437(USA) or 850(Europe), which does not support characters with umlaut, so you must change this to 1252(West European Latin). So, use Chcp command in the beginning of your batch file to change it, like this:

    Chcp 1252
    

    Example: enter image description here

    image via http://www.pctipp.ch/tipps-tricks/kummerkasten/windows-7/artikel/windows-7-umlaute-in-batch-dateien-55616/

    Sources:http://ss64.com/nt/chcp.html , http://www.pctipp.ch/tipps-tricks/kummerkasten/windows-7/artikel/windows-7-umlaute-in-batch-dateien-55616/ (The article says for Windows 7 but this applies for Windows 10 too)