Dan
Dan

Reputation: 693

dir command not current directory and filter

I am trying to list all the files with a specific extension but not the current directory.

Something like this

dir "C:\x y\test\" /b /s *.txt

but instead of the expected result it lists all the files from the specified directory AND the ones from the current directory.

Is there a way to get list the files with a specific extension from another directory than the current one

Upvotes: 0

Views: 600

Answers (3)

Mike S.
Mike S.

Reputation: 2111

I'm not really sure, but i think it would be

dir "C:\some\path\*.txt" /b /s /a-d

Upvotes: 1

the_marcelo_r
the_marcelo_r

Reputation: 1856

How about FORFILES? It's more robust than the old "dir":

FORFILES /P "Your/Path" /S /M *.txt

*/p = The Path to search */s = Recurse into sub-folders

Upvotes: 0

wumpz
wumpz

Reputation: 9151

Do you look for something like

dir "c:\temp\*.txt"

As a fact I am not in c:\temp.

Upvotes: 0

Related Questions