This is a question coming from a former/current Windows user. If I'm looking at a Finder window in a particular directory, how can I search for files with names matching a particular pattern (e.g. "p*.php") that contain a particular string of text?
|
You can't do this from the spotlight icon in the menu bar. But you can do it with spotlight:
Edit: I just grabbed a php file and searched for this string I found this article which explains how to add php as a supported file type for spotlight which should fix the weird result I experienced above. I believe without this change spotlight treats the file as rtf only so some php elements (punctuation especially) will make the search fail. The command to edit the required file is:
You'll want to reindex after this change as the article mentions. It also mentions the more proper way to do this is to install the developer tools. You can then use the method I described above to restrict your search to a specific folder or file type. |
||||
|
|
|
One simple way is Spotlight, in the upper right hand corner of the file window or the desktop screen; that's plain text for file names and strings. Grep is possible with Terminal and *unix commands (Terminal is in Applications/Utilities/). There's Aqua Command-Line Tools, though it looks old. |
|||||
|
|
Some programmer's text editors offer a grep-like feature for searching for a regular expression across multiple files; many (many) moons ago BBEdit had this feature (and probably still does; I just haven't used it for years). I wouldn't be surprised to find that other tools targeted at the developer market also have similar features. |
|||
|
|
|
Both Spotlight and the Finder are an attempt at reaching out to the sort of people who keep the "For Dummies" line of books on shelves, and as such, are not capable of parsing regular expressions or anything else particularly fancy. A lot of people like PathFinder as a replacement but I find it more trouble than it's worth since the Finder will keep launching itself no matter what you do. |
|||
|
|
|
Using AppleScript (and |
|||
|
|