-2

Can anyone tell me why dir *.asp returns all .asp files but also all .aspx files? It seems dir ignores extensions longer than three. This is really bugging.

1
  • -1 you manage to contradict yourself even though you hardly wrote much. While you are correct that "dir *.asp returns all .asp files but also all .aspx files" You then say bizarrely that "dir ignores extensions longer than three" that's wrong. You were right when you said dir *.asp lists .aspx as well.
    – barlop
    Dec 5, 2014 at 1:23

1 Answer 1

0

This is because cmd.exe is broken and will ignore extensions past the first 3 characters when using wildcards. You can use:

dir /B *.asp|find /V ".aspx"

to remove the extra items.

8
  • -1 Why are you saying that DIR will ignore extensions past the first three characters, and then showing that DIR lists the aspx extension. And furthermore, it's just even more wrong to say DIR ignores extensions past the first 3 characters, I just tried creating a file blah.abcq and dir *.abc5 and it didn't ignore the 5 and do dir *.abc which is what i'd expect if DIR were to ignore past the third character. I really can't see what you mean with this ignore past 3 characters. Maybe i'm misinterpreting you, and perhaps you could be more clear re this ignoring point that you make.
    – barlop
    Dec 5, 2014 at 1:28
  • what you suggest would just show *.asp that's good but what you say about DIR ignoring past the first 3 chars I can't see what you are saying there. DIR is placing a wildcard past the first 3 characters but if there was a fourth charcter it doesn't place a wildcard past the first 3, see my above comment.
    – barlop
    Dec 5, 2014 at 1:31
  • @barlop It is broken. Create a directory with both types of files in it. Now type dir *.asp and you'll get both files. Type dir *.aspx and you'll just get the .aspx file. Type dir *.as and you'll get no files. This is inconsistent and is a bug that MS has choosen to leave in for compatibility.
    – krowe
    Dec 5, 2014 at 1:33
  • i'll remove my -1, as your comments explain yourself more.. I think your examples and your statement re it being a bug and inconsistency are good.. But to say it ignores past the first 3 characters ia not a good description of this buggy behavior that you describe.
    – barlop
    Dec 5, 2014 at 1:35
  • The problem is that there are so many of these little bugs left in that cmd.exe is hopelessly useless. The reason I mention the first three characters is because it corrects itself for longer extensions. Try adding a few more files with longer extensions and it works fine again.
    – krowe
    Dec 5, 2014 at 1:43

You must log in to answer this question.

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