-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.
-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.
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.
-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 – 2014-12-05T01:28:16.653
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 – 2014-12-05T01:31:33.710
@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 – 2014-12-05T01:33:17.030
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 – 2014-12-05T01:35:21.747
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 – 2014-12-05T01:43:08.660
are there lists of the bugs in cmd.exe? bugs can make things complicated to deal with but DOS or cmd is so simple that I haven't really seen it affect usage.. Linux commands are so complex that even if a command doesn't have a bug, e.g. even if DIR had 3 bugs it wouldn't be as complex to use/learn as ls or find. And in linux how a wildcard is interpreted depends on a globbing setting within a shell and that setting is buried in some man page somewhere. DOS or cmd's simplicity means even with any bugs it has, it is simple. – barlop – 2014-12-05T02:05:27.150
actually, the find command exists for both OSes and works about the same except that the Linux version uses a real regex parser and the Windows version is a complete mess. Go compare the two and you'll get a good idea about what i'm talking about in general. – krowe – 2014-12-05T02:08:27.453
-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 – 2014-12-05T01:23:34.107