Jump to content

[SOLVED] Searching content of files with specific extension


Recommended Posts

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

 

 

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.

Link to post

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
Link to post
  • vitor changed the title to [SOLVED] Searching content of files with specific extension
  • 4 weeks later...
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. 

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

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