Jump to content
leahcim

[SOLVED] Searching content of files with specific extension

Recommended Posts

Posted (edited)

Hello all

 

as I understand

  1. the default in keyword allows to search contents of a file, but cannot be limited to a certain extension (all parts of the search expression will be used to match against the contents)
  2. the File Filter node in custom workflows allows to filter by extension, but requires to provide the UTI and does not allow to simply search for ".txt" as an extension. Determining the list of available UTIs and their respective extensions is not trivial

 

Is my understanding of above behaviour correct?

Edited by leahcim

Share this post


Link to post

@leahcim For a File Filter, you can drag in an example file of what you'd like to search. For example, if you want to narrow your file filter to txt files only, you can drag in a text file to the File Types box. Adding UTIs manually is completely optional, but might give some users more flexibility. :)

 

Cheers,
Vero

 

 

Share this post


Link to post

Thanks @Vero! Yes, UTIs can be dragged & dropped which is very convenient - however, in my case I want to make it dynamic so that I can specify the extension from Alfred's input box. Therefore, I cannot pre-set any extension filter in the File Filter node, but need to dynamically retrieve it from the input and then set it in the node via a JSON update. And the only solution I've found is to parse the available UTIs from MacOS.

Share this post


Link to post
Posted (edited)

To update, I've got it working now by parsing the available MacOS UTIs and mapping the extensions to UTIs. Little bit of extra work, but it works flawlessly and allows me to search in files of a specific file type.

Edited by leahcim

Share this post


Link to post
On 3/6/2020 at 5:46 PM, leahcim said:

To update, I've got it working now by parsing the available MacOS UTIs and mapping the extensions to UTIs. Little bit of extra work, but it works flawlessly and allows me to search in files of a specific file type.

 

This sounds very useful, but I do not understand how to implement it. Could you share the workflow or give further instructions? Any tips are appreciated. 

Share this post


Link to post
5 hours ago, cands said:

This sounds very useful, but I do not understand how to implement it

 

To get a list of the UTIs known to the system, run the following in a shell:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep '[[:space:]]uti:' | awk '{ print $2 }' | sort | uniq

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