Go Back   Microsoft Operating System Forum > Microsoft Operating System > Windows XP

I'm probably a relic, but I expected the old standard "*" (match zero or more characters) and "?" (match any 1 character) filename wildcarding characters to work in a Command


Microsoft OS Forum to Usenet Gateway is a gateway to Microsoft Windows operating system newsgroups. If you use Windows XP, Windows Vista or any other Microsoft Operating System then this is the community for you.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.

Once you register you'll stop seeing this message.
Log in

Reply
 
Thread Tools Display Modes
Old 09-26-2008, 03:56 PM   #1
Sean Nelson
Guest
 
Posts: n/a
Filename wilcard characters in cmd.exe

I'm probably a relic, but I expected the old standard "*" (match zero or more
characters) and "?" (match any 1 character) filename wildcarding characters
to work in a Command Prompt window. They do work, after a fashion, but not
in the way I would expect. For example:

dir *.d?? displays files such as "Test.docx"

dir *s.* displays files such as "exam.xls"

Interestingly, the same wildcarded search patterns work as I expect in an
Explorer search window.

What exactly are the wildcard characters that cmd.exe accepts, and how are
they interpreted?
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote


Old 09-26-2008, 04:04 PM   #2
Pegasus \(MVP\)
Guest
 
Posts: n/a
Re: Filename wilcard characters in cmd.exe


"Sean Nelson" <SeanNelson@discussions.microsoft.com> wrote in message
news:42D4FD28-2BC6-42DE-8236-E0A07C9772E6@microsoft.com...
> I'm probably a relic, but I expected the old standard "*" (match zero or
> more
> characters) and "?" (match any 1 character) filename wildcarding
> characters
> to work in a Command Prompt window. They do work, after a fashion, but
> not
> in the way I would expect. For example:
>
> dir *.d?? displays files such as "Test.docx"
>
> dir *s.* displays files such as "exam.xls"
>
> Interestingly, the same wildcarded search patterns work as I expect in an
> Explorer search window.
>
> What exactly are the wildcard characters that cmd.exe accepts, and how are
> they interpreted?


You're tripping over the Short File Name (SFN) representation of your files.
When you enter the command
dir test.* /x
then you will immediately see why your own dir command worked the way it
did.


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-26-2008, 04:20 PM   #3
Sean Nelson
Guest
 
Posts: n/a
Re: Filename wilcard characters in cmd.exe

"Pegasus (MVP)" wrote:
> > dir *.d?? displays files such as "Test.docx"
> > dir *s.* displays files such as "exam.xls"


> You're tripping over the Short File Name (SFN) representation of your files.
> When you enter the command
> dir test.* /x
> then you will immediately see why your own dir command worked the way it
> did.


Thanks - that explains the *.d?? pattern match. Is there a way to prevent
matches against the short file names (other than turning off short filename
generation altogether)?

But it doesn't explain why "*s.???" matches "exam.xls", since this file has
no short file name.
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-26-2008, 04:27 PM   #4
Pegasus \(MVP\)
Guest
 
Posts: n/a
Re: Filename wilcard characters in cmd.exe

See below.

"Sean Nelson" <SeanNelson@discussions.microsoft.com> wrote in message
news:EF4D6E72-21F7-436C-B7CB-8226FF147FA3@microsoft.com...
> "Pegasus (MVP)" wrote:
>> > dir *.d?? displays files such as "Test.docx"
>> > dir *s.* displays files such as "exam.xls"

>
>> You're tripping over the Short File Name (SFN) representation of your
>> files.
>> When you enter the command
>> dir test.* /x
>> then you will immediately see why your own dir command worked the way it
>> did.

>
> Thanks - that explains the *.d?? pattern match. Is there a way to prevent
> matches against the short file names (other than turning off short
> filename
> generation altogether)?

No, there isn't while SFN generation is active.

> But it doesn't explain why "*s.???" matches "exam.xls", since this file
> has
> no short file name.

You've got me there. It appears that the "*s" bit picks up the "s" in "xls"
.. . .


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-26-2008, 09:37 PM   #5
Jason
Guest
 
Posts: n/a
Re: Filename wilcard characters in cmd.exe

That would be the difference between ? and *. * means everything - I only
use * at the end.
"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
news:uQz0$6BIJHA.468@TK2MSFTNGP06.phx.gbl...
> See below.
>
> "Sean Nelson" <SeanNelson@discussions.microsoft.com> wrote in message
> news:EF4D6E72-21F7-436C-B7CB-8226FF147FA3@microsoft.com...
>> "Pegasus (MVP)" wrote:
>>> > dir *.d?? displays files such as "Test.docx"
>>> > dir *s.* displays files such as "exam.xls"

>>
>>> You're tripping over the Short File Name (SFN) representation of your
>>> files.
>>> When you enter the command
>>> dir test.* /x
>>> then you will immediately see why your own dir command worked the way it
>>> did.

>>
>> Thanks - that explains the *.d?? pattern match. Is there a way to
>> prevent
>> matches against the short file names (other than turning off short
>> filename
>> generation altogether)?

> No, there isn't while SFN generation is active.
>
>> But it doesn't explain why "*s.???" matches "exam.xls", since this file
>> has
>> no short file name.

> You've got me there. It appears that the "*s" bit picks up the "s" in
> "xls" . . .
>



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
characters, cmdexe, filename, wilcard



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PXE-E53 No boot filename received notagirrafe Windows 2003 Server 3 06-12-2008 03:28 PM
How-to? Configure wilcard (*.domain.com) for Windows Server 2003 TS? Kirstin Windows NT Server 0 03-31-2008 04:25 PM
Filename not displaying. The_Newb_Avenger Windows XP 1 12-09-2007 02:55 AM
Rename *.ITF with filename of TXT file brettmanning24@gmail.com Windows 98 1 10-31-2007 03:13 PM
about 8.3 filename bamsan Windows Vista 3 10-15-2007 07:18 AM




This is a Schwarz Network site.

All times are GMT -5. The time now is 10:57 AM.
Designed by: vBSkinworks