Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list only .doc or .xls files with the Windows dir command in the cmd window?

When using:

dir *.doc

all files that have suffixes .docx, .docm, .doct, and .doc files are listed.

When using:

dir *.xls

all files that have suffixes .xlsx, .xlsm, and .xls files are listed.

Is there a way to use the dir command in the command prompt to only list files with the .doc extension? Or only those with the .xls extension? In other words prevent the results from including .docx, .docm, .xlsx, .xlsm, etc...


1 Answers

You could use findstr to identify filenames ending with ".doc" an no other letters.

dir /s /b *.doc | findstr /I /E "\.doc"
like image 163
lit Avatar answered Nov 28 '25 15:11

lit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!