Reputation: 19546
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?
Upvotes: 5
Views: 6021
Reputation: 8878
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
Upvotes: 6