I needed to search for filenames which contained one specific string ("up"), but did not contain another string ("packages").
However, I was hoping to run it from the command line.
This is actually possible to do, you just have to call findstr
twice.
Mine looked like:
dir /B /S up | findstr /I "up" | findstr /I /v "packages"
That means:
- search all directories (/S & subdirs)
- give me the bare formatting (/B)
- and pass it through (| pipe) findstr (/I ignore case) to find ones that have "up" then
- pass the results (| pipe) through findstr again but this time ignore all that
contain (/v) "packages"
If you have items like:
- c:\test\packages\up
- c:\extra\thing\up
- c:\extra\thing\packages\up
- c:\extra\test\up
- c:\extra\test\nothing
The results would be only the ones that contain "up" but do not contain "packages"
- c:\extra\thing\up
- c:\extra\test\up
Call findstr /v multiple times on result
In other words you can keep passing the result into another findstr with /v to remove the ones that have additional words you don't want.