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.

2
  • 1
    I disagree with the close votes
    – Nifle
    Commented Dec 22, 2011 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 I. These are all duplicates.
    – JdeBP
    Commented Dec 23, 2011 at 15:14

1 Answer 1

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:

2
  • 1
    Which versions of Windows do these apply to?
    – jprete
    Commented Dec 21, 2011 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
    Commented Dec 21, 2011 at 21:50

You must log in to answer this question.

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