Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I searched for the following and it gave me the exact output (folder names changed)

C:\temp>dir *950*.pdf /s
 Volume in drive C has no label.
 Volume Serial Number is ABCDE

 Directory of C:\temp\e\h\d\20100809

08/08/2010  10:54 PM         1,632,434 09_08_2010_004.pdf
08/08/2010  10:54 PM         1,368,895 09_08_2010_003.pdf
08/08/2010  10:54 PM         2,111,360 09_08_2010_005.pdf
               3 File(s)      5,112,689 bytes

I dont understand why "950" is being matched against these 3 files...!

Edit1

I actually moved it into c:\temp\ this time and it matches one of them!

 C:\temp\20100809>dir *950*.pdf
 Volume in drive C has no label.
 Volume Serial Number is ABCDE

 Directory of C:\temp\20100809

08/08/2010  10:54 PM         2,111,360 09_08_2010_005.pdf

Edit2

@gravvity's answer is on the dot!

C:\temp\20100809>dir *950*.pdf /x
 Volume in drive C has no label.
 Volume Serial Number is ABCDE

 Directory of C:\temp\20100809

08/08/2010  10:54 PM         2,111,360 09507E~1.PDF 09_08_2010_005.pdf
share|improve this question
    
Can you reproduce this in another directory structure? – Dennis Williamson Jan 20 '11 at 6:17
    
@Dennis - please see Edit1 – siliconpi Jan 20 '11 at 7:15
up vote 7 down vote accepted
dir /x

For compatibility reasons, Windows generates a 8.3 name for every long file name created, and wildcard matching code (FindFirstFile()) checks both the original and shortened names. Use dir /x to see what short names are assigned to each file.

Usually the auto-generated short names look like 090820~1.PDF and 090820~2.PDF and so on, but there are exceptions:

[...] if at least 4 files or folders already exist with the same initial 6 characters in their short names, the stripped LFN is instead truncated to the first 2 letters of the basename (or 1 if the basename has only 1 letter), followed by 4 hexadecimal digits derived from an undocumented hash of the filename, followed [...]

Moving a file within the same partition does not change either of its names, only relocates them.


When using the NTFS filesystem, 8.3 name creation can be disabled system-wide using:

fsutil behavior set disable8dot3

However, this won't affect existing names.

share|improve this answer
1  
+1 Brilliant answer! (perhaps not so brilliant implementation) – Dennis Williamson Jan 20 '11 at 15:10
1  
+1 Brilliant answer! – siliconpi Jan 20 '11 at 20:50

I have that problem, and was tempted to use fsutil to disable short names systemwide, but decided against it. Instead I found out you can use fsutil.exe to associate the file with a better short name, as in:

fsutil.exe file setshortname 175002886.pdf ~1752886.pdf

You will need to do this as an administrator.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .