10

In a directory, I have 3 files, all with the incorrect file extension jpgJPG.

When I type dir *.j I get no results, as expected.

When I type dir *.jp I get no results, as expected.

But when I type dir *.jpg it lists the 3 files, even though the extension jpg does not match jpgJPG.

Why is the Dircommand behaving this way?

C:\Temp\MediaOrganizer Test Output with Location\2003-10-23 (Temp)>dir
 Volume in drive C has no label.
 Volume Serial Number is 0655-281E

Directory of C:\Temp\MediaOrganizer Test Output with Location\2003-10-23 (Temp)

11/17/2024 10:55 AM <DIR> . 11/17/2024 10:55 AM <DIR> .. 11/17/2024 10:55 AM 897,472 100_0001.jpgJPG 11/17/2024 10:55 AM 966,582 100_0002.jpgJPG 11/17/2024 10:55 AM 1,115,885 100_0003.jpgJPG 3 File(s) 2,979,939 bytes 2 Dir(s) 104,095,875,072 bytes free

C:\Temp\MediaOrganizer Test Output with Location\2003-10-23 (Temp)>dir *.j Volume in drive C has no label. Volume Serial Number is 0655-281E

Directory of C:\Temp\MediaOrganizer Test Output with Location\2003-10-23 (Temp)

File Not Found

C:\Temp\MediaOrganizer Test Output with Location\2003-10-23 (Temp)>dir *.jp Volume in drive C has no label. Volume Serial Number is 0655-281E

Directory of C:\Temp\MediaOrganizer Test Output with Location\2003-10-23 (Temp)

File Not Found

C:\Temp\MediaOrganizer Test Output with Location\2003-10-23 (Temp)>dir *.jpg Volume in drive C has no label. Volume Serial Number is 0655-281E

Directory of C:\Temp\MediaOrganizer Test Output with Location\2003-10-23 (Temp)

11/17/2024 10:55 AM 897,472 100_0001.jpgJPG 11/17/2024 10:55 AM 966,582 100_0002.jpgJPG 11/17/2024 10:55 AM 1,115,885 100_0003.jpgJPG 3 File(s) 2,979,939 bytes 0 Dir(s) 104,095,875,072 bytes free

C:\Temp\MediaOrganizer Test Output with Location\2003-10-23 (Temp)>

phuclv
  • 30,396
  • 15
  • 136
  • 260
mbmast
  • 441

2 Answers2

26

On most Windows systems (older installations especially), files also have a MS-DOS 8.3 style name in addition to their real name. They're a leftover for 16-bit app compatibility. Since the extension is truncated to 3 characters, foo.jpgJPG will have the 8.3 name FOO.JPG (and can be accessed by that name just like by its regular name).

dir /x will show you the 8.3 name (if any) associated with each file.

fsutil 8dot3name controls the generation of 8.3 names. In most cases it can safely be disabled and the names stripped. Newer Windows versions tend to disable it by default.

Note: The setting is for NTFS volumes – as far as I know, short names are required for FAT, as it only had LFNs retrofitted. (I don't know about exFAT.)

grawity
  • 501,077
0

Directorty listings are highly specific across Operating Systems. Semantically, *.j is different than *.j?? - regardless of the 8.3 designation. You are omitting information and Windows is not making a mistake, rather correctly stating its fact as presented. This is not an issue with the Microsoft Operating System.

As written, dir *.j has no files with a .j ending.

C:\Temp\MediaOrganizer Test Output with Location\2003-10-23 (Temp)>dir *.j
Volume in drive C has no label. Volume Serial Number is 0655-281E

Directory of C:\Temp\MediaOrganizer Test Output with Location\2003-10-23 (Temp)

File Not Found

C:\Temp\MediaOrganizer Test Output with Location\2003-10-23 (Temp)>dir *.jp Volume in drive C has no label. Volume Serial Number is 0655-281E

Directory of C:\Temp\MediaOrganizer Test Output with Location\2003-10-23 (Temp)

File Not Found