Page 1 of 1

Dir with wildcard returning unexpected result

Posted: 02 May 2019 15:23
by varianjv
Hi there,
I have a lot of files in a folder

I run the following to get a subset

dir /b pa1*.txt

I would expect this to bring back only files like

pa1.txt
pa11.txt etc

However it also brings back files like
pay1.txt

Any reason for this does any one know

Re: Dir with wildcard returning unexpected result

Posted: 02 May 2019 15:49
by Squashman
It is matching the short file names. 8.3.
Run the DIR command from a command prompt and use the /X option to see what I mean.

Re: Dir with wildcard returning unexpected result

Posted: 03 May 2019 04:52
by varianjv
I'm not using the short name format.
I tried with the /X and i still get filenames I dont want

Re: Dir with wildcard returning unexpected result

Posted: 03 May 2019 08:22
by Squashman
varianjv wrote:
03 May 2019 04:52
I'm not using the short name format.
I tried with the /X and i still get filenames I dont want
Never said you were using short file names nor did I say using /X would solve your problem. I am saying the default behavior is that the WILDCARD will also match short file names.

The EXAMPLE your provided does not output what you say it does because the file names you provided are already in 8.3 format. Don't ever post an example without testing it first.

Go back to the directory that you are having problems with. When you run the DIR command with the /X option you should see that the short file names are matching your search mask.

Re: Dir with wildcard returning unexpected result

Posted: 07 May 2019 14:42
by varianjv
Sorry
I understand what you mean now.
Can I exclude these?