1

I want to make a batch program that creates a folder named fábulas(fables in portuguese). but when I try with the following command

md "DeskTop\fábulas"

The name of the created folder is fábulas.

And when I do the same command in cmd the folder name is fábulas not f├íbulas.

How can I create a batch program that makes the folder name be fábulas instead of f├íbulas

Tata
  • 11
  • 2
  • You should not take the commonly advised route of thinking that a codepage of 65001 is the solution to your issue. What you should do, is save your batch file using the ANSI codepage for your chosen language, i.e. the one which carries all of the characters you want cmd.exe to display correctly, _(any decent text editor should offer this option)_. Then before you need to display those characters, make sure that the batch file changes the codepage to that which you saved the script. In this case, I might advise you use codepage 860 for Portuguese, or 850 for Brazilian Portuguese. – Compo Sep 19 '22 at 12:46
  • Please read my answers on [Using another language (code page) in a batch file made for others](https://stackoverflow.com/a/48982681/3074564) and on [Why are Danish characters not displayed as in text editor on executing batch file?](https://stackoverflow.com/a/43052862/3074564) You encoded the characters stored in the batch file with a different character encoding as `cmd.exe` requires according to the code page set by Windows for the used account according to configured country/region for usage on Windows console. – Mofi Sep 19 '22 at 14:55
  • Some more hints: The directory `Desktop` should contain only shortcut files with file extension `.lnk` and no other files and not any subdirectory. There is the user profile directory for user account related directories and files which are not documents, pictures, videos or music files. If there should be nevertheless created a directory in the user´s desktop directory, I recommend to read [How to create a directory in the user's desktop directory?](https://stackoverflow.com/a/58516212/3074564) – Mofi Sep 20 '22 at 07:00

1 Answers1

1

You should change the code page with CHCP 65001; So you can give a try with this batch :


@echo off
chcp 65001>nul
md "%userprofile%\DeskTop\fábulas">nul 2>&1
md "%userprofile%\DeskTop\áéíóú">nul 2>&1
Explorer "%userprofile%\DeskTop\fábulas"
Explorer "%userprofile%\DeskTop\áéíóú"
Hackoo
  • 18,337
  • 3
  • 40
  • 70
  • 2
    There must be added that this works only if the batch file is stored as UTF-8 encoded text file without byte order mark as otherwise on using the default ANSI code page for the batch file the problem with character encoding used for the batch file not matching the character encoding used by `cmd.exe` on interpreting the lines in the batch file remains. – Mofi Sep 20 '22 at 06:57