Start a new topic

Trickster & AppleScript: add Finder tags

I am trying to use the AppleScript found here to add Finder tags (not color labels) using an Automator Service. 

I am not sure where to place the Trickster AppleScript code to make these work together. 

Here is that AppleScript code, cleaned up for easier pasting into AppleScript Editor:


property ca : current application
property tagname : "todo"
use framework "Foundation"
use AppleScript version "2.4" -- Yosemite or later 
use scripting additions
on run {input, parameters}
	repeat with anItem in input
		set_tag(anItem, tagname)
	end repeat
end run
on set_tag(theFile, atag)
	set tagArray to ca's NSArray's arrayWithObject:atag
	set fileURL to ca's |NSURL|'s fileURLWithPath:(POSIX path of theFile)
	fileURL's setResourceValue:tagArray forKey:(ca's NSURLTagNamesKey) |error|:(missing value)
end set_tag


Hi George,

How exactly do you want the flow to be?

This script's forum post was about setting it in Folder action. How do you want to connect it to Trickster? Which files do you want to add the "todo" tag to?

Aha, yeah I do not want to make it a Folder Action. 

I want to add tags to selected items while I am in Trickster. 

And preferably it would be something that let me choose from a list of tags, but even just one is a help. 

Thank you!

I see.

I tried something now, and this works:

If you noticed, what you right-click files in Trickster, the menu will the Services menu, like in Finder.

You can create custom Services using Automator.

Launch Automator, hit Command-N for New, select Quick Action from the panel.

Choose it to receive Files or Folders and add a Run AppleScript action and paste your script in there.

Then save it using a name you want to see in the Services menu, for example "Set Todo tag".

Here's a screenshot:

After that, you should be able to select files in Trickster and find it in the Services menu, like this:

So odd, this is what I tried first but it didn't work, thought maybe I had to use that Trickster AppleScript. I'm a novice AppleScripter. But it's working now. 

Unfortunately that AppleScript removes existing tags, but that is an AppleScript issue, not a Trickster issue. 

Thanks again. 

Login or Signup to post a comment