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)

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".

  • 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 Dec 10 '19 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 Dec 11 '19 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.