Delete user attributes

While importing hundreds of Markdown files, I wound up with hundreds of useless User Attributes. I can’t copy-and-paste an example, so here’s a screenshot of one.

The settings window expands to accomodate the longest of these phrases, so it extends beyond two screens.

How do I delete these? I hunted for a handy “user attributes” file within the application package and in Application Support, in the hope I could see a list and delete all the gremlins, but didn’t see what I was looking for.

The easiest way to delete a user attribute is:

  1. Open the User Attributes pane of the Document Inspector
  2. Select the unwanted attribute
  3. Choose Delete Attribute from the action menu

It’s not obvious why your Markdown imports created user attributes: presumably, the files appeared to be CSV or TSV tables?

IN a pathological case like this, editing (a copy of) the Tinderbox XML file might be more convenient, especially if you happen to understand the rudiments of XML. If not, you might send the document to tinderbox@eastgate.com and we could do it for you.

For the list above see User tab and:

If you want a list of your user attributes, make a new note, add this code to a stamp:

$Text=;
var:list vList = (document["user-attributes"]);
vList.each(anAttribute){
   $Text+= anAttribute + "\n";
};

and stamp the note.

I didn’t mention that I had started deleting them manually, but it was going to be a long and onerous chore, which is why I was looking for a better solution. But thank you for your guidance.

The MD files were/are straight text. I’ve been using them in a folder shared by Devonthink and Obsidian with no issues.

I poked into the XML, and took the drastic action of deleting all the feral user attributes. That had the drastic effect of killing the file - Tinderbox just opened to a new file. I pasted back what I had cut, and the file still didn’t open. Clearly I shouldn’t fiddle with .xml.

Fortunately it was a file I hadn’t really worked in, even though I created it some months ago. I made a new .tbx file, imported all my material from Devonthink, and am back to the same state as before – but this time, without the feral user attributes. It may be that I used drag-and-drop to import last time, and this somehow resulted in the spawning of new attributes.

If it is of any forensic value, I can email through the file I corrupted containing the feral user attributes.

Almost certainly, when you deleted the user attributes, you accidentally left part of an attribute behind or cut part of the enclosing tags. So, if you could email a copy of the file before you did this surgery — Time Machine is your friend! — I’d be happy to take a look.

Well, all markdown files are straight text; that’s what markdown files are! Could you share one that, when dragged into Tinderbox, makes a user attribute?

As a bit of a tangent to the current question - I’m looking for a way to identify attributes which are “not used” in my main document which stretches back more than 5 years now. I would like to delete and clean them. In many cases I created a new user attribute, used it for a while, decided it not longer useful, copied any values the attribute had into a new attribute and forgot about it.

So what would a typical “orphan attribute” from my point of view is

  • a user defined attribute
  • an attribute for which no value has been given in any note within the file
  • does not appear in DisplayedAttributes in any note within the file

values(“UnusedAttribute”) returns a list of distinct values; if that list contains only one element, the attribute is not assigned any other values.

You could make a set of all the collected values of $DisplayedAttributes:

$MySet =collect(all,$DisplayedAttributes);

Then, if $MySet doesn’t contain “UnusedAttribute”, then UnusedAttribute is not a displayed attribute for any note.

I can’t send you an example file, because I can’t replicate the issue.

I will send the .tbx file, but the corrupted one, because the file lay in an iCloud folder that I hadn’t bothered to back up before my amateur surgery on the .xml

This is all displaying a regrettable lack of competence on my part.

It’s just software. Not something that actually matters. Be kind to yourself.

For later readers who have this issue and want to delete many attributes (once identified) via the TBX’s source XML, here is where you look:

The above is a TBX with a single user attribute SectionName. The TBX is open in BBEdit (available in a free version) with ‘XML’ code colouring turned on and the system attributes XML branch (code lines #4 through #937) collapsed.

Notes (important to read before doing any editing of the XML)…

Undertake this XML surgery only if, having read the notes below, you feel you understand what to do. Even so, always work on a copy of your TBX file. We all make mistakes!

If editing XML use a plain text editor. If you don’t have one/don’t know what they are, get the free version of BBEdit (https://www.barebones.com).

Whether using BBEdit or some other editor, it helps to have line numbering turned on (so you can tell roughly where yo are in the doc).

If in BBEdit select ‘XML’ from the type pop-up in the app window’s bottom status bar. Doing so allows you to collapse sections of the XML, as shown above. Otherwise, use your editing app’s Find to locate the line starting <attrib Name="User". This is the start of the user attributes.

Note that the a complete attribute is from the opening <attrib.. through to the closing </attrib> element. Regardless of whether you have line wrap on (IOW, all info is visible in the current window and doesn’t scroll off-screen right) of of, the </attrib> is always on a separate line to the text defining the attribute. IOW, for each attribute you delete, you will delete two lines of code.

Always work on a copy of your TBX in case you make a mistake.

More info about the TBX XML format is in aTbRef at The XML TBX format.

Footnote: although BBEdit is free, if you find yourself using more than just the one, do consider licensing it. It has all sorts of useful features, not least giving you a place to test regular expressions such as you might use in Tinderbox agent queries or in action code.

1 Like

That’s very useful information, thank you!

I have maintained a current licence to BBEdit for a decade or more. I don’t use anything but a fraction of its horsepower, but sometimes I need to ask bigger things of it, and I value the care that has gone into it.

More rueful than beating myself up, but I appreciate the note.

If there are many attributes to delete an external script can help, e.g.

set unwantedAttributes to {"Unwanted1", "Unwanted2"}
repeat with anAttribute in unwantedAttributes
	tell front document of application "Tinderbox 10"
		delete attribute anAttribute
	end tell
end repeat
  1. copy-paste the script into Script Editor (in Applications > Utilities)
  2. list the names of the unwanted attributes in the first line, separated by commas and with each between "" as shown.
  3. with a copy of your Tinderbox document open and frontmost, click the triangle ‘run’ button in Script Editor.
3 Likes

Most helpful, thanks.

I’d a sense Id’ missed something and thanks to @echuck, we know: createLink(sourceItem, destinationItem[, linkTypeStr])

There is, lest anyone wonder no unlink equivalent, e.g. a ‘removeLink()’, but recent threads suggest that might be useful.