2

It's been well covered how to create a keyboard shortcut for the Tags... menu option in Finder. What I want is a way to tag selected files or folders with a single keyboard shortcut. The same shortcut should untag them.

1
  • Where has it been well covered how to create a keyboard shortcut for tags?? This question is the one I arrive at from a site search looking for that information. Could you please provide a link?
    – Wildcard
    Oct 9, 2016 at 6:13

1 Answer 1

2

The solution is to use the OS X built-in Automator and the great tag command-line utility.

  1. Create a new Service that accepts selected files/folders from Finder (follow the steps here)
  2. In Run Shell Script, select "Pass input:" as arguments and use the following code:

    TAG="Red"
    tag="/usr/local/bin/tag"
    
    for filename in "$@"
    do
      if $tag --list --no-name "$filename" | grep "$TAG\b"; then
        $tag --remove "$TAG" "$filename"
      else
        $tag --add "$TAG" "$filename"
      fi
    done
    

    replacing the value of TAG with the name of the tag you want to use and tag with the location where tag is installed (the one above should be default for brew).

  3. Assign a shortcut to this service in the System Settings.

The script simply checks for each file whether it is already tagged with the given tag, and removes or adds the tag to switch it. You can go fancier from here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .