Windows search tool unable to find files content - Windows 7 - windows-7

Good morning,
I spent almost an hour, trying to find some lines of codes that I knew I had written somewhere but remember in which file.
I tried many things with the Windows search tool to find that file, such as using wildcards (* for a string, ? for a character) or using the content: filter, but it never managed to find it, whereas all files are indexed and I use the search tool often enough to know that it works in those folders (usually searching directly for a file name, not a content).
I did find the file eventually (just opening and scrolling through each of them...), but it still bothers me that this search below wasn't able to find this file, please see screenshot.
Is there any way it is actually possible to make this search work in W7 search tool? It's a .py file, so the content: filter should be able to search inside text files, should it not?

Related

Windows 11 - Not kind sort command for viewing all files in subfolders

I used to use a sort command when trying to view all files across a bunch of folders at once. It makes sorting files easier. I do know part of the command was written as not sort kind, however I am unable to remember which parts need to be capitalised, and where the colon (:) goes. I have trying googling the answer, and even gone through hours of YouTube videos trying to find the answer. I would prefer not to use the asterisk (*) command or the DIR command Screenshot showing one of many attempted iterationsas that is not suitable for my use. Thank you.
I have since been alerted on StackExchange that the answer to the issue I was having is kind:NOT Folder.

Windows search: how to find all files with specified extension and wildcard (like *.csv, *.log, etc)

Using the search input box in File Explorer, how do I find a filename with a specific extension?
Minimal, Complete, Verifiable Example
I'd like to recursively find all comma-separated files in a folder, typically with a .csv extension. For what reason I cannot fathom, all of the following attempts fail to provide this result; they give me a massive list of stuff that I don't need:
*.csv
.csv
name: *.csv
name:=*.csv
I would expect at least one of these to simply print all files with a .csv extension in a sortable list.
This is one of those maddening things that should be simple, but for some reason, is not. I will resist the urge to use profanity, and pine for the search from UNIX, Linux, Windows XP, etc.. which actually make sense.
I just use "csv" and make sure "All subfolders" is selected
Windows Desktop Search: Advanced Query Syntax:
ext:.csv
Windows 7: Advanced tips for searching in Windows:
System.FileName:~>".csv"
Not sure if there is a trick to stop it searching compressed containers or force it to search the entire disk instead of just the index.
Windows Search can never be trusted to find all files, use Everything, Agent Ransack or similar 3rd-party tools if you really are serious about file searching.

Powershell script to remove files that are not in use

I'm trying to write a script that removes all files from a given directory, however I don't want to remove files that are currently in use (being viewed, edited, etc.). What I'm finding is that for some file types (.docx, .xlsx, etc.), this works just fine and the .ps1 script fails as expected and moves on. However, some files (.bmp, .txt) can be open and get deleted as well. It looks like certain files are not locked when in-use. I guess my question is a few smaller questions:
Is there a way to tell if files are in-use (other than seeing if it's locked)?
Is there any definitive way to tell which file types are locked when in-use?
Is there a better cmdlet than Remove-Item to use for what I am trying to achieve?
Thanks in advance!
Some applications like Word locks the file wile reading them to avoid it being modified while it's open (usualy in case you want to modify it in ex. Word). Other applications, like notepad, doesn't.
This is not specific to a filetype (which is just a GUI attribute that has nothing to do with the data inside). It's the application that decides if it wants to lock a file or not. Ex:
Open a docx file in Word: Access denied (file in use)
Open a docx file in Wordpad: Success (no lock)
AFAIK it's impossible to detect 100% files being in use by ex. notepad which doesn't lock files.
There are many ways to delete files, but Remove-Item is as good as any of them.
Adding to Frode's point, nothing wrong with remove-item. Normal directory doesn't offer you much. Files hosted via windows file server provides session information might help you identify if a file is being used. If possible, you may implement a smart logic that excludes the files are in use.
In general, I'd recommend a work around that your powershell script check file's LastAccessTime, say, delete everything that hasn't been accessed for 24 hours
Get-ChildItem -path c:\ps | Where-Object {$_.LastAccessTime -lt (get-date).addDays(-1)}
The extreme way of protecting files, is using SCM and don't delete anything checked out. However this is not a friendly solution to average users.

Searching for files with specific file content

I am trying to edit lot of files which has specific file content. I need to search for those files which have some content.
Is there any software which can do this type of search with huge accuracy.
I have tried searching using Windows 7 but looks like it misses many files.
Thanks.
The Windows native search can be quite limited ...
I'd suggest you look at the File Content Finder app on the Windows app store (disclaimer - I'm its developer). It's specifically designed for searching file contents without indexing. It supports all major file formats - pdf, doc(x), xls(x), pptx, and others. It can even search scanned documents.
Its filtering lets you optimise and refine your search by multiple criteria - file type, creation/modification dates, etc.
You can use FIND "string" pathname or FINDSTR "string" pathname(s)from the windows command line. See this guide.
I face this issue on a daily basis, and I've come up with two solutions:
Text editors, supporting the "find in file" feature (Notepad++ being a simple, free example).
Ubuntu app (from Canonical Group): UNIX/Linux supports finding in files, using the command find . -exec grep ....
As far as Windows search is concerned, its quality has reduced that heavily the latest versions that I've decided not to use it anymore.

How to search Jar files using Windows Search?

I believe back when we were on Win2K, Windows Search would search through Jar files to locate specific classes but this doesn't appear to work in XP. Does anyone know how to enable this in XP?
Note, to do the search in Win2K we just entered *.jar for the files and "ClassABC" for the search text string and the search would return any jar files containing class files where the title contained "ClassABC".
Add this to a text file, save file, change the extension to .reg, double click to add to registry and you should be ok...you can search on file name or content and it should show jars that have class names
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.jar\PersistentHandler]
#="{5e941d80-bf96-11cd-b579-08002b30bfeb}"
The only thing left is to logout and log back into windows and it should work fine for you, see http://support.microsoft.com/kb/309173 for more details
I would also recommend total commander. It is a great file management tool with great search functionality which can easily look inside jar files.
If it was removed it was likely due to the Sun-Microsoft Java dispute that was going on around the time XP was developed. It's unlikely to have a way of re-enabling it.
You might find this helpful instead: http://jarbrowser.sourceforge.net/
Just use FindClassInJars util, it's a simple swing program, but useful.
You can check source code or download jar file at http://code.google.com/p/find-class-in-jars/
I made another version of FindClassInJars here. It is the same look but searches a little better and smarter. Click the "Raw button here:
https://github.com/Oxvalley/FindClassInJars/blob/master/lib/findclassinjars-2.0.0.jar
According to this MSDN Channel 9 article, adding an appropriate IFilter will do it. Since .jar files are the same as .zip files, one of the four ZIP file IFilters they list might work (unless they are all extension-based).
From Brenden Anstey's Blog:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.jar]
"Content Type"="application/x-zip-compressed"
"PerceivedType"="compressed"
#="CompressedFolder"
[HKEY_CLASSES_ROOT\.jar\CompressedFolder]
[HKEY_CLASSES_ROOT\.jar\CompressedFolder\ShellNew]
"Data"=hex:50,4b,05,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
[HKEY_CLASSES_ROOT\.jar\OpenWithProgids]
"CompressedFolder"=""
[HKEY_CLASSES_ROOT\.jar\PersistentHandler]
#="{098f2470-bae0-11cd-b579-08002b30bfeb}"
[HKEY_CLASSES_ROOT\.war]
"Content Type"="application/x-zip-compressed"
"PerceivedType"="compressed"
#="CompressedFolder"
[HKEY_CLASSES_ROOT\.war\CompressedFolder]
[HKEY_CLASSES_ROOT\.war\CompressedFolder\ShellNew]
"Data"=hex:50,4b,05,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
[HKEY_CLASSES_ROOT\.war\OpenWithProgids]
"CompressedFolder"=""
[HKEY_CLASSES_ROOT\.war\PersistentHandler]
#="{098f2470-bae0-11cd-b579-08002b30bfeb}"
[HKEY_CLASSES_ROOT\.ear]
"Content Type"="application/x-zip-compressed"
"PerceivedType"="compressed"
#="CompressedFolder"
[HKEY_CLASSES_ROOT\.ear\CompressedFolder]
[HKEY_CLASSES_ROOT\.ear\CompressedFolder\ShellNew]
"Data"=hex:50,4b,05,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
[HKEY_CLASSES_ROOT\.ear\OpenWithProgids]
"CompressedFolder"=""
[HKEY_CLASSES_ROOT\.ear\PersistentHandler]
#="{098f2470-bae0-11cd-b579-08002b30bfeb}"
I know that it's not Windows Search, but I have long used Agent Ransack for this: it is very quick and searches through all the various java archive formats (jar, war, ear) as well as zip.
A feature that I particularly like and use a lot is saving a search: you can save the criteria (so that you can repeat that search easily) or the results.. So when I am working on a project, I will often want to search through the project directory tree for a file (or a file within a jar/zip). I perform the search once and save the criteria as a .srf file, which I can open quickly to perform similar searches afterwards.
As suggested by #iubing, the FindClassInJars code works fairly well, but the author must have botched the packaging.
I've forked the FindClassInJars util from google code, you can get a built copy here that works. Just click the "raw" button.
a while back I developed this: https://github.com/javalite/jar-explorer just for the occasion. works even on windows :)

Resources