Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Dec 21 '11 at 17:12

This question came from our site for professional and enthusiast programmers.

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 I. These are all duplicates. –  JdeBP Dec 23 '11 at 15:14

2 Answers 2

up vote 33 down vote accepted

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:

share|improve this answer
2  
Wow, nice catch! +1 –  schnaader Dec 21 '11 at 17:41
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

this command will delete each file whose name contains 1. string:

DEL *1.*

this command will delete each file whose name contains e. string:

DEL *e.*

if you are trying to delete each file whose full name end with the number one, you have to use:

DEL *1

if you are trying to delete each file whose extension end with the number one (and name does not contain a period sign), you have to use:

DEL *.1
share|improve this answer
    
This doesn't answer the OP's question, nor add anything to the approved answer above. –  tricasse Sep 5 '12 at 11:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.