25

I'm trying to delete all files that end with the number one, but for some reason it is deleting all of the files in the folder.

The command I'm using is

DEL *1.*

It works when I use a letter like

DEL *e.*

but when I use a number everything is deleted.

Mithical
  • 321
  • 1
  • 3
  • 14
Alex
  • 323
  • 3
  • 7
  • 1
    I disagree with the close votes – Nifle Dec 22 '11 at 10:46
  • The fact that one question asks about `dir` and wildcard behaviour and the other question asks about `del` and the same wildcard behaviour doesn't actually make them different questions, Nifle. The _behaviour of the wildcards in matching names_ is the core of the question. It's frequently asked, and this duplicate is almost in canonical form. grawity answered it twice before. [So have](http://superuser.com/questions/238900/248976#248976) [I](http://superuser.com/questions/63777/248977#248977). [These are all duplicates](http://superuser.com/questions/179479/251220#251220). – JdeBP Dec 23 '11 at 15:14

1 Answers1

36

Windows keeps an 8.3 file name for every file to ensure compatility.

So if you have the files

test1.ext
test2.ext
test3.long

the last file gets stored with the alternative name

TEST3~1.LON

thus matching the pattern *1.*.

You can execute dir /x to see all 8.3 file names.

Fixes:

  • To strip all files in the directory directory of their 8.3 name, execute

    fsutil 8dot3name strip directory
    
  • To strip all files in the directory directory of their 8.3 name, including those in subdirectories, execute

    fsutil 8dot3name strip directory /s
    
  • To disable 8.3 file names on the drive drive: (only affects newly created files), execute

    fsutil 8dot3name set drive: 1
    
  • To disable 8.3 file names altogether (only affects newly created files), execute

    fsutil 8dot3name set 1
    

For the complete syntax, execute

fsutil 8dot3name strip & fsutil 8dot3name set

Furhter information:

Dennis
  • 48,917
  • 12
  • 130
  • 149
  • 1
    Which versions of Windows do these apply to? – jprete Dec 21 '11 at 21:45
  • 1
    @jprete: Long file names (and thus, wildcard quirkiness) exist since NT 3.5 in 1994. `fsutil` was introduced in XP, if I remember correctly. – Dennis Dec 21 '11 at 21:50