windows - Find directories with file match 1 but not file match 2
2014-07
I feel like I should have been able to find this with simple googling/searching here but haven't managed so... Basically the same as this question of at AU but for Windows.
I want to find directories that have a file with name including (for example) 02
or 03
but do not have a file with a name including 01
. I'd prefer a nice CLI command but I'm open to installing anything less than Ubuntu (or other *nix distro).
For example:
\music\The Irish Roves\Hardstuff\
01 - All Sing Together.mp3
02 - Paddy On The Turnpike.mp3
...
\\shouldn't match that folder
\music\Garth Brooks\Ropin' The Wind\
03 - What She's DOing Now.mp3
\\but should match this one
Figured out how to do this.
Requires the Microsoft free program Powershell. Just install that and then the command is:
Cmd:
$a = gci path/to/look/at -r | ? {$_.PSIsContainer -eq $True} | ? {$_.GetFiles().Count -ne 0}
$a = $a | ? {Test-Path($_.fullname+"\*02*")} | ? {(Test-Path($_.fullname+"\*01*")) -eq $False}
$a | select FullName
You can also do that as a oneliner but wrote it multiline for easier reading here.
That cmd is also using some shortcuts; gci
= Get-ChildItem
and ?
= Where-Object
and select
= SelectObject
.
Thanks to arielnmz for pointing me in the right direction
In Windows XP we can search for files that contain a defined keyword (inside all files types).
Windows 7 can look inside files for a keyword, but only for text files. (*.doc, *.txt, *.inf, ...
), not (*.conf, *.dat, *.*, ...
).
Microsoft search filters don't contain any filter I can use for this.
How is this possible?
To get to the Indexing Options:
Start --> Control Panel --> Indexing Options
See Change advanced indexing options for more information.
If you click on the Advanced button in Indexing Options and go to the File Types tab, you will get a list of file types and the way they are indexed. For the file types you want, you can specify that you want the file contents indexed, and not just the file properties.
Or you can just do a normal search, and after the search is finished you can click on the "File Contents" button under the "Search again in" field (which is located after the end of the search results list, if you scroll to the bottom).
Based on this page, the "File Contents" option won't always show up - only when the folder being searched is not marked for file content indexing; in that case, file contents are supposedly searched automatically, without having to specify this option explicitly.
I've always gotten better performance when searching inside files by using a GREP tool. I'm a fan of AstroGrep.
I believe you can also just enter "content:blahblah" in the search filter box in upper right corner of Windows Explorer. This works at least for Text files and Office documents. It also works for source files.
You can play with findstr.
findstr /s /m searchstring *.*
Agent Ransack is always worth a look. It's free, fast, good reputation, and doesn't use indexing.
In Windows Explorer, menu Tools -> Folder Options:
Press on the search tab and here, the first option: what to search, choose to search for non-indexed files inside the file.
Windows 7 still has the ability to search for strings inside files everywhere (and not in indexed locations).
In Windows Explorer, go to menu Tools/Folder options and select "Always search file names and contents".
Probably the file types still have to be set up correctly in Advanced Options of Indexing Options".
Have you tried search the internet for the correct iFilter (for instance - http://www.ifilter.org/)?
If you have the right iFilter, Windows should be able to search and index its content.
The answer by Sean Sexton gave me what I was looking for (putting "content:" in the search text box). But I think the following graphical explanation might be of help to others.
The equivalent of this search in XP Search Companion (dog):
is this in Windows 7:
In Windows XP you could add further (text) file types to be searched via the registry:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.dita\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
I'm not sure whether this works with Windows 7 as well.
Windows 7 SP1 ignores content: and contents: for me now, and it looks like the mechanism has changed: Now you type in what you want, and as soon as the search starts, a row at the bottom shows up with "Search again in:" Libraries, Computer, Custom, Firefox, and most importantly, File Contents. Click that and it restarts the search within files, even if the folder is unindexed.
Notepad++ can do this and is free. Find in files is CTRL-SHIFT-F.