AppleScript: Batch creating user attributes

I’ve edited the post above to include a revised script with a stab at including color and interval.

In the vast majority of cases (string, number, list without embedded ; and set without embedded ; and date) it would seem at most a simple conversion on the AppleScript side does the job. My suggested simple date-to-string conversion works well for me, as it lets AppleScript worry about Unix and all that, but there many other approaches.

color (if using AppleScript RGB triplet list and not just "red","green", etc.) and interval require more complicated conversions, with possible approaches in the script.

And if there are embedded ; within AppleScript list items (presumably not a common scenario) the conversion can get a little messy. Tinderbox needs a \ to escape the ; and AppleScript needs a \ to escape the \ that it passes to Tinderbox. Also, as noted, after you get the escaping right, you find it works well with a list attribute but results in surrounding "" in a set attribute (part of the internal “de-duping”?). From a user perspective it would make sense to have the same behavior with a list as with a set. Perhaps one should be using surrounding "" for both?

But, yes, this is a powerful and already highly usable implementation! These sorts of issues are normal in the AppleScript world. When using AppleScript with this or any other app it seems there is no substitute for the old “shove the stick down into the pile, twist it around, and see what emerges” approach. Just back up carefully first and wear thick gloves and boots.

I had just assumed that type: will be mandatory in the make new attribute statement. It would be helpful to have default: and suggested: but perhaps their use can be optional in the statement?

Over time the AppleScript-related documentation presumably will touch on such points as permissible attribute names.

1 Like