When I run the following line:

dir C:\FILENAME *.bat /b > C:\TEXTFILE.txt

I receive the following in the TEXTFILE.txt:

BATCHNAME.bat
BATCHNAME.bat

How can I make it output just the name of each file once?

有帮助吗?

解决方案

Use this:

dir C:\FILENAME\*.bat /b > C:\TEXTFILE.txt
               ^
     note the added backslash

Assuming you're in the c:\filename directory, your original command will get two copies because it's asking for two separate things.

其他提示

dir C:\FILENAME\*.bat /b > C:\TEXTFILE.txt

You are asking dir command to list two different sets of files, the content of C:\FILENAME and (there is a space between) the list of all .BAT files in current directory. So, two lines into the output file

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top