Share via

Bug in the DIR command?

Anonymous
2021-01-12T16:16:50+00:00

Hi all.  I'm running Win 10 Version 10.0.17134.1365 and recently I've been testing long file names and how they're handled in an application that I work on.  Strangely I noticed that when I try to see what the short name is for one of these files, they're not displaying correctly.

Here's an example:

Long name: rr6129739dkn79phk2t2hf5pggn3vn1p4x76sj6qw4366j60v14dg93hh6vgr96g64wmhd10bvtvlv7nsdpww5dkl1mw995k3pn0vr10ltv9455qrzl8kwsbprwnwz65dwgld71rxbjj26nn2c3nsv4gwmwc8c3420wcns7vg24x7k3nxrkvl43c84pb8flv78bgl74gqqt7ktf10szcckth7stjzgc9df97n9rgjzqz01234567.txt

Short name SHOULD be: RR3560~1.TXT

What CMD.EXE's DIR command displays:

C:\tmp>dir /X rr6*

01/11/2021  12:27 PM                 4 RR3560~1.T   rr6129739dkn79phk2t2hf5pggn3vn1p4x76sj6qw4366j60v14dg93hh6vgr96g64wmhd10bvtvlv7nsdpww5dkl1mw995k3pn0vr10ltv9455qrzl8kwsbprwnwz65dwgld71rxbjj26nn2c3nsv4gwmwc8c3420wcns7vg24x7k3nxrkvl43c84pb8flv78bgl74gqqt7ktf10szcckth7stjzgc9df97n9rgjzqz01234567.txt

And the same incorrect short name is displayed if I instead use the   /-N  option

As an alternative I find I need to use Cygwin to reliably get the short names, so the data DOES exist. 

$ find /cygdrive/c/tmp/rr6* | xargs -r cygpath -d

C:\tmp*RR3560~1.TXT*

And then if I round-trip that short name displayed by Cygwin into the DIR command again, it resolves to the correct long file name:

C:\tmp>dir /B RR3560~1.TXT

rr6129739dkn79phk2t2hf5pggn3vn1p4x76sj6qw4366j60v14dg93hh6vgr96g64wmhd10bvtvlv7nsdpww5dkl1mw995k3pn0vr10ltv9455qrzl8kwsbprwnwz65dwgld71rxbjj26nn2c3nsv4gwmwc8c3420wcns7vg24x7k3nxrkvl43c84pb8flv78bgl74gqqt7ktf10szcckth7stjzgc9df97n9rgjzqz01234567.txt

Does anyone else see this error with DIR on their Win 10 machines?  

P.S.  If you want to create that long file name just use Save As from Notepad.

Windows for home | Windows 10 | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2021-01-12T18:08:25+00:00

    The bug disappears when you limit the length of the file name to 247 or less. This might be an easy fix until MS gets around to fixing the bug (which could take some time).

    Was this answer helpful?

    0 comments No comments