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

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?

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:
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)

Related

CMD: '■m' is not recognized as an internal or external command

I am trying to get a batch file to work. Whenever I attempt to run a .bat the command line returns '■m' is not recognized... error, where "m" is the first letter of the file. For example:
md c:\testsource
md c:\testbackup
Returns
C:>"C:\Users\Michael\Dropbox\Documents\Research\Media\Method Guide\Program\test
.bat"
C:>■m
'■m' is not recognized as an internal or external command,
operable program or batch file.
Things I have tried:
Changing Path variables, rebooting, etc.
Changing file directory (i.e. run from C:)
Running example files from web (like above) to check for syntax errors.
Thanks
What text editor are you writing this in? It seems like your text editor may save the file as UTF-16 encoded text, which cmd.exe can't handle. Try setting the "coding"/"file encoding" to "ANSI" when saving the file.
This results in the first byte being a byte-order-mark (telling other editors how to process the file), and cmd.exe can't deal with this.
In addition to the approved answer I would add the case where is a PowerShell command the one that creates the file... PowerShell comes by default with the UTF-16 encoding.
To solve your problem then, force the file encoding lie this: | out-file foo.txt -encoding utf8
Answer based on this other answer.
In windows 10 I had the same issue.
Changing the character set to UTF-8 made it worse.
It worked correctly when I selected Encoding as UTF-8-NO BOM.

Vim. Troubles with encoding on file saved in windows

I have ��� chars after each time I save file in windows for some folders. And for some other folders - all is fine. I can't find difference between folders where everything is fine and folders where files saving with bad endings. So I have to run dos2unix in my linux virtual machine on modified files every time. Since these files is javascript - it's very annoying!
Help me, where to dig? How to avoid appearing of ��� chars at the end of file?
:set fileencoding=utf-8 does not help.
Usually vim has for dos files - [dos] label at the bottom of buffer window - in my case all is fine, and no [dos] label there.
This looks more like a file format problem than encoding. I recommend adding this to your ~/_vimrc:
set fileformat=unix
set fileformats=unix,dos
set nobinary
You can find more details in :help fileformat

Batch Lines not showing up correctly

Trying to add some lines ╔═╬ to my batch files. The issue I am having is that they do not show up properly in CMD.
I am using Windows 7 Professional.
Change your codepage, maybe? In your bat file, issue a chcp 437
I had to use CHCP 65001 to get the characters to work correctly for me.
I've seen this one a few times... Open the file in Notepad and Save as ... make sure to change the Encoding to ANSI ... (right next to the Save button)

International characters in a batch file

Hey, I'm having some problems writing a batch file where I need to specify some file paths containing international characters (the norwegian letter 'ø' to be exact).
For example, the filename axporteføljedb.vbp (which looks normal in notepad) turns into axportef°ljedb.vbp on the command line, which the system then goes on to complain about not finding.
Any suggestions?
It will work if you save your batch file as ANSI with a Norwegian character set (with Notepad++ for example). Then, in the cmd, when you want to run your batch file, first change the code page to something that supports Norwegian: chcp 1252 (in the console).

Why is there a difference between the encoding of the Windows Command Prompt vs. a batch file?

For example, suppose I have a batch file called 'test.cmd' and it simply contains:
echo %1
I can call this directly from the command prompt with 'test.cmd some¬arg' and the result is that the string 'some¬arg' is printed.
However if I place that same call in a second batch file, called 'tester.cmd' for the sake of argument, and I call this from the command prompt the result is that the string 'some%arg' is printed.
What is it that messes up the encoding and how do I get around it? I am sure I've fixed this before, but I can't remember how...
Thanks!
This is because your batch file is encoded in a different code page than cmd.exe is currently in.
In western default configurations, cmd.exe starts in CP850, but text editors usually work in CP1252 (what is often wrongly referred to as Latin-1 or ISO-8859-1).
The characters "¬" and "¼" share the same character code in these two code pages, "BC".
The solution is simple. Either encode your batch file in code page 850, or switch cmd.exe to code page 1252 by issuing chcp 1252.

Resources