Jump to content

Workflow for Content Search within single Taskpaper file


Recommended Posts

I have downloaded a few workflows for content searches within files (PDF, Mindnode etc) but can't seem to get this to work for my intended workflow.

 

OBJECTIVE:

I'm trying to search for content within a single, large taskpaper file that I use to log clippings, URL's, and notes. I'd like to search this file for keywords/key phrases and have Alfred display all instances of the keyword where it occurs in the document.

 

HERE'S WHAT I'VE GOT SO FAR:

I've created a workflow that 1)Matches the taskpaper file format 2) Searches only the directory where the file is located (is there a better way to search within just one file?) and 3) includes the kMDItemTextContent field filter. 

 

I can't get it to work. I successfully access the workflow with a keyword and the minute I start typing it becomes a google search? 

 

I've written/modified quite a few workflows but I just can't figure out what I'm doing wrong here. 

 

Any and all help is appreciated!

Link to post
7 hours ago, bb13 said:

HERE'S WHAT I'VE GOT SO FAR:

I've created a workflow that 1)Matches the taskpaper file format 2) Searches only the directory where the file is located (is there a better way to search within just one file?) and 3) includes the kMDItemTextContent field filter.

 

It sounds like you're using a File Filter. That isn't able to do what you're asking:

 

7 hours ago, bb13 said:

have Alfred display all instances of the keyword where it occurs in the document.

 

File Filters don't show any results beyond the names of matching files. If you want to show results from within a file, you're going to have to write your own Script Filter based on grep or ripgrep (or something else that can extract sections of a file).

Link to post
6 hours ago, bb13 said:

I thought Alfred could search within certain files?

 

It can, but you said you wanted the workflow to “display all instances of the keyword where it occurs in the document”.

 

A File Filter can only show the names of files, not extracts from them, which is largely pointless, as you only want to search one file.

Link to post

Thanks for responding and trying to help me, @deanishe. So is what I'm trying to do impossible without writing a Script Filter to accomplish this? I've been searching workflows but haven't found any that seem similar, have you run across any that might be *close* to what I'm trying to do? Thanks again.

Link to post
23 minutes ago, bb13 said:

So is what I'm trying to do impossible without writing a Script Filter to accomplish this?

 

That's right.

 

23 minutes ago, bb13 said:

I've been searching workflows but haven't found any that seem similar, have you run across any that might be *close* to what I'm trying to do?

 

Not that I recall. The first step is relatively easy: grep the file and convert the results to Alfred Script Filter feedback. Or use a library that can actually parse the files into tasks, tags etc..

 

Where it gets difficult is opening the file to the location you selected. You'll need to be using an application with an appropriate API to open a file at a specific line. It's child's play in vim, but YMMV with other programs.

Edited by deanishe
Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...