Jump to content
bb13

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!

Share this post


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).

Share this post


Link to post

@deanishe is there a way to include the "IN" search parameter in the workflow. I thought Alfred could search within certain files?

 

Share this post


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.

Share this post


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.

Share this post


Link to post
Posted (edited)
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

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...