Windows – Why does `dir *.*` give me all files and folders

command linedirdirectory-listingfilenameswindows

When I run dir *.* it produces unexpected results. Even files and folders without any dot in their names are listed. For example

C:\>dir *.*
 Volume in drive C is System
 Volume Serial Number is AC0A-29DA

 Directory of C:\

14-03-2017  05:17 PM             8,192 ntuser.dat
03-01-2017  07:10 PM    <DIR>          Perl520
28-03-2017  10:13 AM    <DIR>          Program Files
28-03-2017  10:13 AM    <DIR>          Program Files (x86)
04-01-2017  03:25 PM    <JUNCTION>     Python27 [C:\Program Files\Anaconda]
06-02-2017  10:16 PM    <DIR>          SAP
28-03-2017  04:10 PM               152 useragent.log
03-01-2017  03:04 PM    <DIR>          Users
16-03-2017  04:24 PM    <DIR>          VM
22-03-2017  11:13 AM    <DIR>          Windows
               2 File(s)          8,344 bytes
               8 Dir(s)  270,172,966,912 bytes free

Why is that? Is there any way to list only files with a dot?

Best Answer

I am writing this answer because OP has emphasized that:

what I'm interested is why *.* matches all files, as stated in the question

The DIR command comes from a time when:

  1. Period (.) was not allowed as a character in file or folder names
  2. File and folder names were restricted to 8 characters for name and 3 characters for extensions

Therefore, by that standard, *.* meant whatever the name and whatever the extension. It did not mean a string containing a ".", which may or may not have characters before or after the ".".

Microsoft policy is preserving backward compatibility. Hence, that interpretation of *.* is retained.

But in Windows PowerShell, *.* means a string containing a ".", which may or may not have characters before or after the ".".

Related Question