How to search only the filename for a substring in Windows?

1

0

Following on from this question, I'd like to know whether Windows Search also shares the same shortcomings, or whether it is possible using Advanced Query Syntax to search for a substring in the filename only, leaving out the extension?

What I mean is, is it possible to search for something like, say, "zip" in only the filename such that the following valid filenames are returned?

zip
has zip
zip.doc
azip.zipx
textzip.txt
has zip text
File.zip.txt
zipper.winzip
File - zip text.zip
this file name haszipin it.txt

The following are invalid filenames since they do not contain the string "zip" in the filename portion, but only in the extension. These should be excluded.

noname
File.xzip
File.zipx
File.azipx
File.bxzip
File name.zip

Karan

Posted 2012-12-03T23:18:20.927

Reputation: 51 857

use Everything and regexp. – Apache – 2012-12-03T23:26:09.677

@Karan, do you mean in the find box of Explorer? I gave up using that (in Vista+) a long time ago because it is just horrible to use. Just today, I was trying to find all localization files (e.g., *fr_fr*, *es_es*, etc.) and could not get it to work no matter what combinations and permutations I tried. – Synetech – 2012-12-03T23:26:54.607

2@Shiki: Note that I mentioned Windows Search and AQS specifically. This question is not about looking for alternatives - I have plenty of those, thanks. – Karan – 2012-12-03T23:28:51.110

1@Synetech: Yes, that's what I'm talking about. file:zip or filename:zip seems to look in exensions as well, just like dir, so I'm wondering if there's any way at all to overcome this, perhaps by excluding ext: somehow. – Karan – 2012-12-03T23:30:11.767

"How to ...?" is grammatically incorrect. – artistoex – 2013-05-27T09:32:12.587

Answers

4

You could exclude zip files from the index but I know that isn't really answering your question. I use a freeware program called Everything that lets me choose what files to index and you can use regular expressions in that search in order to get more exact results (like what you're looking for). As far as I'm aware, windows search doesn't allow regular expressions but maybe you can attach a second parameter to the search like *zip*.* && not *.zip Not sure if that's possible though.


Edit: Since I (Karan) just tweaked Codezilla's last attempt posted in chat, it wouldn't be proper to add it as a separate answer. All credit goes to him (Edit: and to Scott as well) for discovering 95% of this search term, which seems to correctly identify the 10 valid filenames and leave out the 6 invalid ones:

*zip* NOT "*.*zip*" OR filename:"*zip*.*zip*"

So it can be done, but not without jumping through hoops. Confirmation of the fact that Windows Search sucks. Couldn't they have simply added proper RegEx support?

Codezilla

Posted 2012-12-03T23:18:20.927

Reputation: 828

Yeah, you can see my comment above about alternate tools. As for AQS itself, I've tried but seems it searches for the substring in the extension as well for some reason. I need a way to restrict the search to file: or filename: and exclude ext:. I tried using NOT, but couldn't get it to work properly, so I'm hoping someone can help. – Karan – 2012-12-03T23:33:09.137

does *zip*.* -*.zip not work? – Codezilla – 2012-12-03T23:38:40.317

Think maybe I figured it out, try: *zip*.* -"*.zip" You have to use quotes to get it to look at it seriously apparently. This is probably the case with a lot of results you may be getting that aren't what you expect. Er, well, this just finds the solution to the zip problem but I think you mean globally excuse all extensions or something? – Codezilla – 2012-12-03T23:41:51.167

Nope, any single substring will do. Unfortunately, *zip*.* -"*.zip" seems to also return File.azipx, File.bxzip, File.xzip, File.zipx etc. (see my valid and invalid filenames list above). – Karan – 2012-12-04T00:09:36.227

Add asterisks in the extension so it'll check for any extension with zip in it. *zip*.* -".zip*" – Codezilla – 2012-12-04T00:12:20.497

let us continue this discussion in chat

– Codezilla – 2012-12-04T00:15:25.480

1Doesn’t the last term need to be "*zip*.*zip*"?  Does the expression you have now catch azip.zipx or zipper.winzip? – Scott – 2012-12-04T23:52:25.990

@Scott: I didn't get a notification regarding your comment, so saw it just now. Thanks a lot for pointing out more edge cases and providing a fix as well! – Karan – 2012-12-09T15:44:39.153

1

filename:*zip*. (note the . at the end) seems to work fairly well on Window 7 — equivalent to filename:*zip*.* — except it doesn’t find files with no extension.


<edit>
For example, I created a new folder and created these empty files:

                                enter image description here

(Look familiar?)  The display is sorted by modification date to preserve the order.  Then I typed filename:*zip*. into the Search box, and I got

enter image description here

i.e., all the files that have zip in the file name (exclusive of the extension) and have a (non-null) extension.
</edit>

Scott

Posted 2012-12-03T23:18:20.927

Reputation: 17 653

filename:*zip*.* seems to return the exact same files as filename:*zip*. and filename:*zip*, and these include files with "zip" in the extension but not the filename. – Karan – 2012-12-04T00:01:31.853

Hi, just saw your edit. I don't know what to say really. On Windows 7 x64 I created a brand new folder just now (so it is unindexed), created 14 0-byte files with those exact same names, then copy-pasted your search string i.e. filename:*zip*. and it returned 13 names as results out of the 14, with only noname excluded. :( Will look into this again when I get back from work, but there clearly seems to be a major discrepancy here. (Oh, and I haven't modified any advanced file type indexing options on this system either.) – Karan – 2012-12-04T00:51:00.270

I am shocked — shocked! — to learn that Windows behaves inconsistently. – Scott – 2012-12-04T00:58:10.680

Hi, I checked again on a different Windows 7 Home Premium x86 PC (previous one was Ultimate x64), and it behaves the same way (1 filtered, 13/14 displayed). So at least it seems to behave consistently on the two machines I've tried so far. – Karan – 2012-12-04T15:17:43.783

0

I know this is old, but for future people who read it, check out https://msdn.microsoft.com/en-us/library/windows/desktop/aa965711%28v=vs.85%29.aspx

You should be able to accomplish this by "filename:zip NOT fileext:.zip" or even "file:zip -ext:.zip"

Sir Launcelot

Posted 2012-12-03T23:18:20.927

Reputation: 99