"dir *1" returns unexpected files

Table of contents
  1. 1. Comments

Check this out:

(XP) start > run “cmd” [enter]

echo dumdididum > a-file_1.txt
echo dumdididum > a-file_2.txt
echo dumdididum > a-file_3.txt

echo tweedledee > a-filetoo_1.txt
echo tweedledee > a-filetoo_2.txt
echo tweedledee > a-filetoo_3.txt

echo tweedledee > a-filetree_1.txt
echo tweedledee > a-filetree_2.txt
echo tweedledee > a-filetree_3.txt

echo justforfun > a-file-with-no-numbers.txt

dir /b *1.txt

a-file-with-no-numbers.txt
a-filetree_3.txt
a-filetree_2.txt
a-filetoo_1.txt
a-filetree_1.txt
a-file_1.txt

emphasis added.

what’s going on here?

(I’ll post the answer in the comments later. But it took me and a friend and some generous netizens to get to the root of it.)

Comments

  1. Prokhor wrote:

    So what’s the deal with it?

  2. matt wilkie wrote:

    Hi Prokhor,

    The deal is, dir matches by the the short 8 character name (the DOS name), while returning the long filename.

    Thanks for asking. I had to look a moment or so to remember! Unfortunately I can’t locate my bookmark for the discussion which finally clued us into what was happening so I regretfully cannot credit the true discoverers.

    Send feedback