I often want to navigate to a file or folder that does not have a unique name. Instead, the parent folder in combination with the file or foldern name makes it unique. Here are a few examples:
- I want to open
readme.txt
in the folder calledABC
rather thanreadme.txt
in the folder calledCDE
orFGH
. - Each year I teach a subject where the folders are organised
subjectname/2011
,subjectname/2012
, etc. I want to be able to searchsubjectname 2012
because2012
is not unique.
When i enter a part of the path and the filename into Spotlight, the file is not found. Spotlight does not seem to treat path information as relevant to the search.
- What is a quick way of navigating to a file using spotlight when its name is not unique but you know a word or partial word that appears in its path?
- Alternatively, is there another strategy for quickly locating a file or folder by name and a word in the file or folder's path?
Update, I have read that Spotlight treats the path in a special way. It can't be used in constructing searches.
kMDItemPath
Complete path to the file. This value of this attribute can be retrieved,
but can't be used in a query or to sort search results. This attribute can’t
be used as a member of the valueListAttrs array parameter for MDQueryCreate
or MDQueryCreateSubset.
Value Type: CFString
Framework: CoreServices/CoreServices.h
Header: MDItem.h
Availability: Available in OS X v10.4 and later.
Best Answer
If you're comfortable opening the terminal you could run the command
and it will give you the full file path to any files on your machine that are named readme.txt in a folder named ABC.
While you're there you can copy and past the path as an argument to the
open
command and it will open it for you.Taking it one step further you can use the output of
locate
as the arguments foropen
withxargs
Will open all files that have ABC/readme.txt on your machine just as if you had double-clicked them.