Jump to content

Add additional filtering to file actions

Recommended Posts

The file actions only filter by file type, that works well in most situations but not all of them. For example, if I want to add file actions to git folders, my only recourse is to assume all folders are git folders since the file type is 'public.folder'. If it was possible to filter by filename, I could take one more step and filter by type _and_ by name, e.g., directories with names that match '*.git'. Best of all would be the ability to execute a script that indicated whether the file action was applicable. Here's an example of the possible configuration:


Name: Open in SourceTree

Name: [ ] Accepts multiple files



Files only (optional): false

Filename pattern (optional): <none>

Script filter (optional): (bash)

    if [ -f {query}/.git/HEAD ]

        echo true
        echo false
This would add 'Open in SourceTree' to every directory that included a .git/HEAD file under it.
I'm aware that this has the possibility to be very "heavy" in constructing the list of possible file actions. One way to minimize that heaviness is requiring Types regardless of whether a script is provided, that way the script will only be executed when the appropriate file types are detected.
Lastly, I would like an option to make a filter applicable to only files. There are some actions which are never applicable to directories but applicable to every file, e.g., Path Finder 'Add to Drop Stack' doesn't work on directories.
Link to comment
Share on other sites

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