PC Review


Reply
Thread Tools Rate Thread

dir and del command in CMD.exe perform wildcard match on short filename

 
 
PiErre
Guest
Posts: n/a
 
      17th Jan 2007
(my pc is winxp-pro sp2 - C: is ntfs 12GB)
I tested both with and without cmd
extensions (cmd /E:ON and cmd /E:OFF): no change

I had many files old-* and an important file
o.log.some.other.extension.doc
in the same directory; I issued a simple command

del ol*

and the important file was erased too!

Is this by design?
Isn't this quite dangerous?
Is there a way of obtaining the wildcard match only on LONG filenames?


here is an detailed example


C:\zz>dir
Volume in drive C is xxxx
Volume Serial Number is zzzz-zzzz

Directory of C:\zz

2007-01-17 11:23 <DIR> .
2007-01-17 11:23 <DIR> ..
2007-01-17 11:23 0 o.log
2007-01-17 11:23 26 o.log.gz
2 File(s) 26 bytes
2 Dir(s) 1,713,643,520 bytes free

C:\zz>dir ol*
Volume in drive C is xxxx
Volume Serial Number is zzzz-zzzz

Directory of C:\zz

2007-01-17 11:23 26 o.log.gz
1 File(s) 26 bytes
0 Dir(s) 1,713,643,520 bytes free

C:\zz>dir /x
Volume in drive C is xxxx
Volume Serial Number is zzzz-zzzz

Directory of C:\zz

2007-01-17 11:23 <DIR> .
2007-01-17 11:23 <DIR> ..
2007-01-17 11:23 0 o.log
2007-01-17 11:23 26 OLOG~1.GZ o.log.gz
2 File(s) 26 bytes
2 Dir(s) 1,713,643,520 bytes free

C:\zz>del ol*

C:\zz>dir
Volume in drive C is xxxx
Volume Serial Number is zzzz-zzzz

Directory of C:\zz

2007-01-17 11:24 <DIR> .
2007-01-17 11:24 <DIR> ..
2007-01-17 11:23 0 o.log
1 File(s) 0 bytes
2 Dir(s) 1,713,643,520 bytes free

C:\zz>



bye,
PiErre

 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      17th Jan 2007

"PiErre" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> (my pc is winxp-pro sp2 - C: is ntfs 12GB)
> I tested both with and without cmd
> extensions (cmd /E:ON and cmd /E:OFF): no change
>
> I had many files old-* and an important file
> o.log.some.other.extension.doc
> in the same directory; I issued a simple command
>
> del ol*
>
> and the important file was erased too!
>
> Is this by design?
> Isn't this quite dangerous?
> Is there a way of obtaining the wildcard match only on LONG filenames?
>
>
> here is an detailed example
>
>
> C:\zz>dir
> Volume in drive C is xxxx
> Volume Serial Number is zzzz-zzzz
>
> Directory of C:\zz
>
> 2007-01-17 11:23 <DIR> .
> 2007-01-17 11:23 <DIR> ..
> 2007-01-17 11:23 0 o.log
> 2007-01-17 11:23 26 o.log.gz
> 2 File(s) 26 bytes
> 2 Dir(s) 1,713,643,520 bytes free
>
> C:\zz>dir ol*
> Volume in drive C is xxxx
> Volume Serial Number is zzzz-zzzz
>
> Directory of C:\zz
>
> 2007-01-17 11:23 26 o.log.gz
> 1 File(s) 26 bytes
> 0 Dir(s) 1,713,643,520 bytes free
>
> C:\zz>dir /x
> Volume in drive C is xxxx
> Volume Serial Number is zzzz-zzzz
>
> Directory of C:\zz
>
> 2007-01-17 11:23 <DIR> .
> 2007-01-17 11:23 <DIR> ..
> 2007-01-17 11:23 0 o.log
> 2007-01-17 11:23 26 OLOG~1.GZ o.log.gz
> 2 File(s) 26 bytes
> 2 Dir(s) 1,713,643,520 bytes free
>
> C:\zz>del ol*
>
> C:\zz>dir
> Volume in drive C is xxxx
> Volume Serial Number is zzzz-zzzz
>
> Directory of C:\zz
>
> 2007-01-17 11:24 <DIR> .
> 2007-01-17 11:24 <DIR> ..
> 2007-01-17 11:23 0 o.log
> 1 File(s) 0 bytes
> 2 Dir(s) 1,713,643,520 bytes free
>
> C:\zz>
>
>
>
> bye,
> PiErre
>


Run the command

dir c:\zz /x

You will then see that the 8.3 file name matches your
wild card. That's why you lost the file!


 
Reply With Quote
 
PiErre
Guest
Posts: n/a
 
      17th Jan 2007

Pegasus (MVP) wrote:
>
> Run the command
>
> dir c:\zz /x
>
> You will then see that the 8.3 file name matches your
> wild card.
> That's why you lost the file!


ehm, I though it was clear
from the subject of my post that I already
discovered that! (it was already present in a command I posted)
What concern me is the fact that the filematch is on
the short filenames and not on the long ones...
Why is it so?

I would say it was a precise
design choice, but I cannot see the reason behind it...

More important: is there a way to change
this odd behaviour of filematching mechanism
in cmd.exe?

TIA!
bye,
PiErre

 
Reply With Quote
 
AJR
Guest
Posts: n/a
 
      17th Jan 2007
Have not seen the original post - however "CMD" (contrary to many opinions)
is equivalent to the MS-DOS prompt which has never had "long filename"
capability - I would like to have a quarter for every instant of that fact
in publications.

"PiErre" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Pegasus (MVP) wrote:
>>
>> Run the command
>>
>> dir c:\zz /x
>>
>> You will then see that the 8.3 file name matches your
>> wild card.
>> That's why you lost the file!

>
> ehm, I though it was clear
> from the subject of my post that I already
> discovered that! (it was already present in a command I posted)
> What concern me is the fact that the filematch is on
> the short filenames and not on the long ones...
> Why is it so?
>
> I would say it was a precise
> design choice, but I cannot see the reason behind it...
>
> More important: is there a way to change
> this odd behaviour of filematching mechanism
> in cmd.exe?
>
> TIA!
> bye,
> PiErre
>



 
Reply With Quote
 
Wesley Vogel
Guest
Posts: n/a
 
      17th Jan 2007
Command.com is 16-bit and cannot handle long names only 8.3 short names.

Cmd.exe is 32-bit and can handle long or short names.

Cmd.exe is the Windows Command Processor and was developed for NT.

You CANNOT use long file names with command.com, quotes or no quotes. At
least with the Chdir (Cd) command.

------
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.

C:\>cd C:\Documents and Settings\Wesley P. Vogel\Local Settings\Temp
Too many parameters - and

C:\>cd "C:\Documents and Settings\Wesley P. Vogel\Local Settings\Temp"
Parameter format not correct - "C:\Documents

C:\>cd C:\DOCUME~1\WESLEY~1~VOG\LOCALS~1\Temp

C:\DOCUME~1\WESLEY~1\LOCALS~1\TEMP>
------

Too many parameters
There are too many spaces in the command you are typing. Valid format is
8.3 names.

Parameter format not correct
You typed one or more parameters that do not have a valid format for this
command. Valid format is 8.3 names.

Cannot Use Spaces in MS-DOS Command Parameters
http://support.microsoft.com/kb/229880

Native MS-DOS Commands and the Space Character
http://support.microsoft.com/kb/166827

Amazingly enough, this command works in command.com:

md "A Directory With a Long Name"

You can use long file names with cmd.exe.

You have to use quotes with some commands with cmd.exe, especially if the
path contains a white space.

Try the following commands in cmd.exe and see what happens...

start "" "C:\Program Files\Internet Explorer\iexplore.exe"

start "C:\Program Files\Internet Explorer\iexplore.exe"

start C:\Program Files\Internet Explorer\iexplore.exe

start iexplore

<quote>
Remarks
Using multiple commands
* You can use multiple commands separated by the command separator && for
string, but you must enclose them in quotation marks (for example,
"command&&command&&command").

Processing quotation marks
If you specify /c or /k, cmd processes the remainder of string and quotation
marks are preserved only if all of the following conditions are met:

* You do not use /s.
* You use exactly one set of quotation marks.
* You do not use any special characters within the quotation marks (for
example: &<>( ) @ ^ |).
* You use one or more white-space characters within the quotation marks.
* The string within quotation marks is the name of an executable file.

If the previous conditions are not met, string is processed by examining the
first character to verify whether or not it is an opening quotation mark. If
the first character is an opening quotation mark, it is stripped along with
the closing quotation mark. Any text following the closing quotation marks
is preserved.

File and directory name completion correctly processes file names that
contain white space or special characters if you place quotation marks
around the matching path.

The following special characters require quotation marks: & < > [ ] { } ^ =
; ! ' + , ` ~ [white space]

If the information that you supply contains spaces, use quotation marks
around the text (for example, "Computer Name").
<quote>
from CMD...
Paste the following line into Start | Run and click OK...

hh ntcmds.chm::/cmd.htm

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In news:ec1$(E-Mail Removed),
AJR <(E-Mail Removed)> hunted and pecked:
> Have not seen the original post - however "CMD" (contrary to many
> opinions) is equivalent to the MS-DOS prompt which has never had "long
> filename" capability - I would like to have a quarter for every instant
> of that fact in publications.
>
> "PiErre" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>
>> Pegasus (MVP) wrote:
>>>
>>> Run the command
>>>
>>> dir c:\zz /x
>>>
>>> You will then see that the 8.3 file name matches your
>>> wild card.
>>> That's why you lost the file!

>>
>> ehm, I though it was clear
>> from the subject of my post that I already
>> discovered that! (it was already present in a command I posted)
>> What concern me is the fact that the filematch is on
>> the short filenames and not on the long ones...
>> Why is it so?
>>
>> I would say it was a precise
>> design choice, but I cannot see the reason behind it...
>>
>> More important: is there a way to change
>> this odd behaviour of filematching mechanism
>> in cmd.exe?
>>
>> TIA!
>> bye,
>> PiErre


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
long filename -> short filename conversion incorrect Han Windows XP General 7 15th Dec 2008 04:39 PM
How to query 2 tables and then perform a wildcard search using a 3 DB Dummy Microsoft Access Queries 1 16th Oct 2008 10:36 PM
FileSearch FileName using wildcard (?) Werner Rohrmoser Microsoft Excel Programming 1 16th Jun 2005 10:35 AM
Wildcard for numeric characters in filename? Jeff Microsoft Excel Programming 4 6th Dec 2004 10:32 PM
searching a list box for a filename match...and highlighting the match suee Microsoft Excel Programming 1 13th Apr 2004 02:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:13 PM.