When I do a search:
dir /b /s *.txt
I get all files/folders with the extension .txt
. But I also get them when they have an extension like .txtx
. How can I search for the exact extension?
When I do a search:
dir /b /s *.txt
I get all files/folders with the extension .txt
. But I also get them when they have an extension like .txtx
. How can I search for the exact extension?
you can try this
dir /s /b *.txt | findstr /v .txt.
or
dir /s /b *.txt | findstr /e .txt
or
dir /b *.txt | findstr .txt$
I can't figure out why it behaves like this, but this works: dir /b /s .txt | findstr /e .txt
. Ugly but works.
dir C:\XML /s /b | findstr /e .xml > C:\XML\list.txt
this works for me, just change the .xml extension to .txt
Splitting the commands for better understanding:
dir /s /b
^ ^
| |
| Displays a **bare** list of directories and files, with no additional information.
|
~ Lists every occurrence of the specified file name within the
specified directory and all **subdirectories**.
findstr /e
^
|
Matches the text pattern if it is at the **end** of a line.