I have been annoyed by a strange behavior of cmd.exe for a long time (at least WinXP and Windows7). A command like del *.txt will also remove *.txt1 files (any number of characters after '.txt' will do). Is this a well known bug or what?
|
| |||
|
feedback
|
migrated from stackoverflow.com Jul 4 '11 at 10:16
This question came from our site for professional and enthusiast programmers.
|
It's an occasionally-encountered somewhat-known? An explanation of the behavior is here, complete with a possible work-around. Summary: It comes from the way NTFS handles short (8.3) filenames, for compatibility with older stuff that can't handle "new-fangled" long filenames.
Extensions longer than three characters will simply be truncated for their short filename; so | |||
|
feedback
|
|
Files with more than 4 letters in the extension (and other rules of course also apply), get a short name, so for example "foo.txt1" has the shortname "foo~1.txt". | |||
|
feedback
|
|
Would this be on a FAT/VFAT filesystem? If so, you're getting bitten by the hackery used to represent names that don't fit into the 8.3 schema; there's a | |||
|
feedback
|
|
You can probably use "Forfiles" command for a workaround Eg. Forfiles -s -m *.txt -c "cmd /C del /q @path" Matches only "txt" endings. | |||
|
feedback
|
