Jump to content
jordic

Add and remove alfred:ignore from comments

Recommended Posts

Hi, 

 

I've created a simple workflow to manage my 'alfred ignore list'. It reuses some PHP code from jdwarrior. I hope that's not a problem :-)

 

The workflow contains a file action to add the alfred:ignore comment to a file. This will make Alfredapp ignore the file and not show it as a search result anymore. Type 'ignorelist' to display a list of all currently ignored files. Selecting a file will remove all spotlight comments (beware!) and will make Alfred list it in the search results again. 

 

I hope it's of use to anyone else. It helps me to get rid off all the annoying and useless apps showing up in my results. Again, it blatantly removes all spotlight comments right now and I've not tested it thoroughly yet, but I'll try to fix any issues asap.

 

You probably need to reload Alfred's cache after using this workflow: just type 'reload' and select 'Reload Alfred Cache'.

PS: Any way to do that programmatically?

 

Download: http://cl.ly/3P092T38282j

 

regards, J.

Share this post


Link to post

I think you could detect whether a comment already contains "alfred:ignore" with something like this:

 

set string1 to "coucou"
set string2 to "cou"
if string2 is in string1 then display dialog "yay"

 

and then using the comment already existing in a file to add "alfred:ignore" (only if it isn't already in it), to the previous comment without erasing it, something like this:

 

set existing_comment to comment of theFile
set comment of theFile to existing_comment & " " & "alfred:ignore"

 

 

Also, I'm not sure you need to write your "ignorelist" to a file since the command mdfind (command line for a spotlight search, quite fast) allows you to search for a file by kMDItemFinderComment, which is the file's comment. 

 

Finally, I know there is a simple way to remove a string from a string with php or bash. So i would assume that also exists in applescript (if you decide to stick with it and not use bash for mdfind). 

 

 

Anyway, I really like your workflow ;) I never use the comments so I don't care if it erases it  :P

Share this post


Link to post

Thanks for the suggestions Florian. I've reworked the workflow. It now handles existing comments and leaves them intact. I'm not keeping a list of ignored files. I use mdfind to dynamically construct the list. I've change the keyword to a default keyword ignore not to confuse people.

 

 

Download: http://cl.ly/032U2J2l2f0z

Share this post


Link to post

@jordic Thanks for posting this workflow! Does it still work in Alfred 3 (& current Mac OS)?

 

On my machine, I can only get the file action to work for 1 file at a time (not multiples). In addition, the search feature is a little sporadic. However, it might just be my machine.

 

Thanks again!

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