Jump to content

Rename tags with applescript


Recommended Posts

I want to rename some of my existing tags. Those with a <space> in the name should change. E.g. from "applescript tag" to "applescript_tag".

I wrote this script

tell application "Evernote"
	set tagNameList to name of every tag
	repeat with i from 1 to number of items in tagNameList
		set this_tag to item i of tagNameList
		set trimmedTag to my replace_chars(this_tag, " ", "_")
		log this_tag
		log trimmedTag
		if (this_tag is not equal to trimmedTag) then set name of this_tag to trimmedTag
	end repeat
end tell
on replace_chars(this_text, search_string, replacement_string)
	set AppleScript's text item delimiters to the search_string
	set the item_list to every text item of this_text
	set AppleScript's text item delimiters to the replacement_string
	set this_text to the item_list as string
	set AppleScript's text item delimiters to ""
	return this_text
end replace_chars

But it gives errors: error "Can’t set name of \"applescript tag\" to \"applescript_tag\"." number -10006 from name of "test pyramid"

Any idea what goes wrong?

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...