Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS helpfulness when using Dir

Status
Not open for further replies.

jaymaechtlen

Technical User
Jul 19, 2004
124
0
0
US
Well - it seems that Windows has some features I haven't noticed until now -

I can't believe I just learned this - noticed in Win 7, but does same thing in a Win 2K vm.

In a command window, dir *.doc will also return .docx files.
hm, that's almost cool.

And, in VBA, the behaviour holds -
strFile = DIR("C:\*.doc",vbnormal)

will pull .doc and .docx files.

dir *.do returns nothing (unless there's something actually present named that)
dir *.do? returns .doc and .docx

If I want <only> the .doc files, would I have to check the actual file names returned?
Or, is there a way to force it to only return a string match of the file type

Thanks
Jay
 
This isn't as clever as you might think. "dir *.doc" will also return *.doctorwho and *.doctorno, for example.

Sorting (with /OE) in a command window gives all the .doc files first, but you can't do that with the VBA version so, sorry, but you just have to check the returned names one by one - it's easy enough code but slightly irritating.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top