Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

marked as duplicate by Bob, iglvzx, Dennis, slhck, Mokubai Jun 16 '12 at 6:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

1 Answer 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.)

share|improve this answer
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 '12 at 6:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.