Announcement

Collapse
No announcement yet.

Problem with "é" in directory name

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with "é" in directory name

    I have a problem with this line:
    @start "" "C:\privé\test.txt"

    When I try the line from the command line, there is no error.
    When I try the line from a batch file, there is an error. The error is: Cannot find the file C:\privé\test.txt
    The "é" character is displayed "strange" in the error message, not as an "é".
    Is there a solution without changing the directory name "privé" in another name?
    Last edited by dreivilo47; 23rd October 2017, 18:47.

  • #2
    You've just run into Windows' inconsistent handling of non-ASCII character sets.

    An accented character typed in a regular command window is not the same as the exact same character typed into a Windows application like, say, Notepad. In other words, if you edit batch files using a Windows application that assumes encoding type Windows 1252 or somesuch, accented characters will appear mangled when viewed from the command line.

    Possible solutions:
    1. Create/edit your batch files with a Windows application that allows you to specify the encoding of non-ASCII characters in text files. In the US, codepage 437 is usually the one you want, while Western Europe uses codepage 850. For instance, LibreOffice Writer will let you do this if you choose File > Open and select "Text - Choose Encoding" from the file type pulldown menu.
    2. Use a command-line editor. I believe the Nano editor is available for Windows.
    3. Switch to PowerShell, which uses Windows encoding.
    4. Ugly workaround: Use redirection and the echo command to place the required character(s) at the end of your file (echo é >> yourfile.cmd), and then use cut and paste to put the character(s) in the right place(s). The character will look wrong in a Windows application like Notepad, but will function correctly when used in a cmd shell environment.
    5. Very impractical workaround: Don't use accented characters in paths or filenames.

    Comment


    • #3
      Thank you for the fast reply and for the possible solutions Ser Olmy!
      I prefer solution 4, the ugly workaround. It's easy, fast and effective.
      Thanks again, my problem is solved!

      Comment

      Working...
      X