Dir wildcards matching all extensions

  • Thread starter Thread starter Curt Dixon
  • Start date Start date
C

Curt Dixon

If I have files

test.tst
test.tst1
test.tst2

and I run "dir *.tst" at a cmd prompt, I get back all 3 files. Running "dir
*.ts?" and "dir *.t??" does the same thing. del works the same way (as
probably most wildcard cmds do).

This causes real problems if I want to delete all .res files but not .resx
files. Is there any way around this?
 
If I have files

test.tst
test.tst1
test.tst2

and I run "dir *.tst" at a cmd prompt, I get back all 3 files.
Running "dir *.ts?" and "dir *.t??" does the same thing. del works
the same way (as probably most wildcard cmds do).

This causes real problems if I want to delete all .res files but
not .resx files. Is there any way around this?

For all that I know Windows does no handle more then 3 characters file
extension.
 
For all that I know Windows does no handle more then 3 characters file
extension.

Easy to test - change the file names
test.tst to test.ts
test.tst1 to test.ts1 and
test.tst2 to test.ts2

If it is now possible to distinguish the "*.ts", then indeed
Holz was spot-on (which he is).

Ed
 
Curt Dixon said:
If I have files

test.tst
test.tst1
test.tst2

and I run "dir *.tst" at a cmd prompt, I get back all 3 files. Running
"dir
*.ts?" and "dir *.t??" does the same thing. del works the same way (as
probably most wildcard cmds do).

This causes real problems if I want to delete all .res files but not .resx
files. Is there any way around this?

Unless you turn off the "Short File Name" (SFN) facility, all file
names have both an SFN and an LFN. Commands using a wild
card will produce a match if either the SFN or the LFN matches.

You will now find that the LFN extension of "test.tst1" is ".tst1".
The SFN extension for the same file ist ".tst". In other words,
there is a match for *.tst.

To see your SFNs, use this command:
dir /x
 
Holz said:
For all that I know Windows does no handle more then 3 characters file
extension.

Then change them to 4 chars.

test.test
test.test1
test.test2

Now "dir *.test" returns 1 file. "dir *.tes" returns all files.

There seems to be a special case bug when searching with 3 char extensions.
No doubt left over from the 1980's DOS days.
 
Curt Dixon said:
Then change them to 4 chars.

test.test
test.test1
test.test2

Now "dir *.test" returns 1 file. "dir *.tes" returns all files.

There seems to be a special case bug when searching with 3 char
extensions.
No doubt left over from the 1980's DOS days.

Nope. Not a bug - it's part of the SFN translation. Use dir /x
to see what I mean.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top