9

Why does:

dir "test.txt "
dir test.txt.
dir "test.txt    . .   ."

all lists test.txt with no error on Windows prompt? Are there any other suffix that are ignored by Windows?

(please note that I added space, dot to the end of the filename)

1 Answer 1

8

The Windows shell does not allow a file or folder name to end with dot or space. There are low level routines that automatically trim any trailing dots and/or spaces in many situations, including when used with DIR.

I found the following confirmation that names cannot end with dot or space in a Microsoft's Windows Dev Center article: Naming Files, Paths, and Namespaces

Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not. However, it is acceptable to specify a period as the first character of a name. For example, ".temp".

2
  • 1
    Thanks for you answer, that's what I thought. I would really like to find some source about the way Windows removes those characters. And especially if there are other characters concerned.
    – Guillaume
    Commented Dec 10, 2019 at 23:11
  • 2
    @Guillaume - See my updated answer with a reference. Based on the Microsoft article, I would say no other characters are affected.
    – dbenham
    Commented Dec 11, 2019 at 0:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .