Output the contents of the DIR command to a file with a specific extension

I have the following command that I have in the BAT file:

dir /b /s /-p *.sas /o:n >"%CD%"\WIN_file_list.txt 

The goal is to have a file containing the full path ONLY of files with the extension .sas.

The problem is that when you run the above script, it outputs everything with sas to the extension. The file contains all the .sas files that I want, but also all the .sasb7dat files that I do not want in the new txt file.

Any insight would be appreciated.

Thanks in advance.

+4
source share
1 answer

Use findstr to filter:

 dir /b /s /-p *.sas /o:n | findstr /E .sas >"%CD%"\WIN_file_list.txt 
+5
source

All Articles