IronMensan
IronMensan

Reputation: 6831

How do I keep dir from matching short file names?

I have a batch file that includes a dir command that is trying to match files that end with a 1.

dir *1.*

This does not work because dir matches both the short and long versions of file names. So while MyFileName.ext does not match *1.*, MYFILE~1.EXT does and so MyFileName.ext is included in the results. How can I prevent dir from matching against short file (8.3) file names?

Upvotes: 1

Views: 220

Answers (1)

Random832
Random832

Reputation: 39000

You can't - you'll have to match them some other way. Try dir /b | findstr ".*1\..*".

Upvotes: 3

Related Questions