List all files with certain extensions in Windows folder in a single call

batch-file

Solution

Use a space to separate the file masks:

dir /b *.csv *.xsl *.txt > results.txt

Note that you can also sort the output, and the sort is applied across the entire list. For example, to sort by name:

dir /b /o:n *.csv *.xsl *.txt > results.txt

Problem

I would like to get all `.txt`, `.csv`, and `.xsl` files in a particular directory and write the filenames to a file. I can just call it three times in a batch file like ``` dir /b *.csv > results.txt dir /b *.xsl >> results.txt dir /b *.txt >> results.txt ``` But can I do it in one line?

Original source