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 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.– barlopDec 5, 2014 at 1:23
Add a comment
|
1 Answer
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.
-
-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.– barlopDec 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.– barlopDec 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. Typedir *.aspx
and you'll just get the.aspx
file. Typedir *.as
and you'll get no files. This is inconsistent and is a bug that MS has choosen to leave in for compatibility.– kroweDec 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.– barlopDec 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.– kroweDec 5, 2014 at 1:43