evanfuchs Posted February 21, 2016 Posted February 21, 2016 I would like to be able to first search/filter by file name, and then search within the contents of the resulting files. For example, "2015 receipt" returns my 2015 receipts (filenames with the words "2015" and "receipt"), then "milk" returns those files from the previous results that contain the word "milk" within their contents. I thought I could get there with a File Filter --> Open File, using kMDItemDisplayName and kMDItemTextContent, but no luck yet. Am I close, or would this call for some scripting? Thanks!
Andrew Posted February 23, 2016 Posted February 23, 2016 I would like to be able to first search/filter by file name, and then search within the contents of the resulting files. For example, "2015 receipt" returns my 2015 receipts (filenames with the words "2015" and "receipt"), then "milk" returns those files from the previous results that contain the word "milk" within their contents. I thought I could get there with a File Filter --> Open File, using kMDItemDisplayName and kMDItemTextContent, but no luck yet. Am I close, or would this call for some scripting? Thanks! What you have done should work fine, I set up a file filter with no config changes other than: Then was able to find files with words in the name / content as you suggested. Are the files you looking for within your search scope? Cheers, Andrew
evanfuchs Posted February 23, 2016 Author Posted February 23, 2016 Hi Andrew, Thanks for replying. Yes, the files are within the search scope. This works to filter name OR context for either/both words, but it yields too many results for me. In my example, every document whose contents or name "2015" and every document whose contents or name contain "milk" will show. I'm hoping to filter the name on one value and the contents on the other. I was able to do it by specifying the value of kMDItemDisplayName in the filter itself, but I'd like to do it on the fly. Thanks, Evan
Andrew Posted February 23, 2016 Posted February 23, 2016 Hi Andrew, Thanks for replying. Yes, the files are within the search scope. This works to filter name OR context for either/both words, but it yields too many results for me. In my example, every document whose contents or name "2015" and every document whose contents or name contain "milk" will show. I'm hoping to filter the name on one value and the contents on the other. I was able to do it by specifying the value of kMDItemDisplayName in the filter itself, but I'd like to do it on the fly. Thanks, Evan You have hit a limitation of the file filter in its present form - this is something which I am going to look at improving in the future! I'm sure I've seen a workflow by one of Alfred's longer term enthusiasts which does advanced file filtering with scripting, but I can't seem to find it right now... hopefully somebody else can chime in here. Cheers, Andrew evanfuchs 1
deanishe Posted February 25, 2016 Posted February 25, 2016 I'm sure I've seen a workflow by one of Alfred's longer term enthusiasts which does advanced file filtering with scripting, but I can't seem to find it right now... hopefully somebody else can chime in here. Are you perhaps thinking of Fuzzy Folders? That's no good here: it works on filepaths only. Smart Folders does something related, but can't do what OP wants. You could implement this as a Script Filter using mdfind. The trick would be defining/determining which parts of the query apply to the filename and which to the contents. This command would match the "milk receipt" example: mdfind -onlyin ~/Documents 'kMDItemDisplayName=2015 && kMDItemDisplayName=receipt && kMDItemTextContent=milk'
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now