1

Possible Duplicate:
How to extract a complete list of extension types within a directory?

Suppose there are three files, a.txt b.txt c.exe under folder c:\dir\, is there any command that I could get the two file extensions names .txt and .exe.

3
  • 1
    Just remove the /s in dir /b /s /a:-d "%target%" in my answer to exclude subdirectories.
    – Bob
    Jun 16, 2012 at 3:09
  • A solution for powershell is here: superuser.com/a/397961/26503 Jun 16, 2012 at 6:12
  • This should work: dir /a-d /b | sed -e "s/^.*([.][^.]*)/\1/g" | sort | uniq Nov 15, 2012 at 1:45

1 Answer 1

1

I'm not sure what you're asking. I think you want to know a DOS command to list all files with a filename extension ending in both .txt and .exe? For that I'd just type in "DIR C:\DIR\*.EXE; C:\DIR\*.TXT" (Notice the space after "DIR" and a space after the semicolon. Also don't include the quotes.)

1
  • No. The body of the question is confusing, but the title is more clear. They wanted to query a directory and get a list of unique file extensions based on the files present.
    – iglvzx
    Jun 16, 2012 at 6:34

Not the answer you're looking for? Browse other questions tagged .