Delete custom metadata fields


Would these scripts presumably still work with Big Sur? I don’t know code and was wondering if @pete31 (or someone) could perhaps walk me through these steps due to a hangup I’m experiencing. My workflow:

  1. Installed “List and Record Tools” per developer’s instructions
  2. Open a new AppleScript window. So as not to confuse the first script from the second, I named the first one Part-1 before I pasted-in Pete’s first script. Running it gives me this:

Encouraging! So let’s say I now choose/select “mdoclc” (third from bottom in my list) because I know for certain I have roughly 10 records in my entire database in which I assigned, manually, some alphanumeric (single-line) text in this custom metadata field. I then click OK. But now what? (I have been able to ascertain, by clicking OK, I get mdoclc and nothing more/less in my clipboard. Is that all the first script is supposed to do?)

The problem I’m having, is what I’m supposed to do next. i.e. I don’t understand what this means:

Identifiers are not deduplicated as this can be done in a text editor, e.g. BBEdit Text > Process Duplicate Lines.

Perhaps normal behavior; when I paste your second script into a new AppleScript window and click the little hammer icon, I get an error:

My goal is just to see all instances of my custom metadata field called OCLC before I vaporize it once and for all. I presume your second script is supposed to get me there, but I can’t determine what I’m doing wrong. Any guidance would be great. Thanks!

1 Like

First off, let’s name scripts:

  • Script 1: Copy Identifier (Copy Custom Meta Data Identifiers from plist)
  • Script 2: Main script (Delete Custom Meta Data )
  • Script 3: Verify main script’s result (Write Custom Meta Data Identifiers to file)

The text in brackets is the name of each script as in it’s first line.

This is not the order in which I posted them here.

No idea, still on Mojave.

Yes, it only copies one meta data’s identifier on each run. Paste each meta data you want to delete in the main script’s property deleteMetadataNames.

This is referring to script 3, the one that verifies the main script’s result. It outputs a text file with all meta data identifiers that are used in the selected records.

“Not deduplicated” simply means you’ll get a full list of every selected record’s meta data identifiers - instead of a deduplicated list. I did a lot of testing before I used the scripts and for that it was better to get a full list.

If you want to see whether the meta data was successfully removed you have to deduplicate it somewhere, e.g. in BBEdit. That’s of course not necessary; you could check the full list manually and watch out whether one of the meta data you removed wasn’t removed. After all you could simply forget about script 3 - I wrote it for testing purposes, it’s not necessary at all.

However you could of course use it to get a full list before you use script 2 to see what meta data is currently used.

I can compile it in Script Editor. Please make the whole script visible in Script Editor, try to compile again and post a capture of the window.

Somehow I completely missed the obvious:
property deleteMetadataNames : {"mdtest1", "mdtest2"} -- set your Meta Data Identifiers here

I should be good to go but want to ask again about the query question from my OP yesterday. Your comment was of course probing if I wished to permanently delete both the metadata itself and the custom labels (custom metadata) I made, in DT3. Indeed the answer remains yes to both, but I want to first examine all the files in my database in which I actually entered something in a those (single-line text custom metadata) fields I’m planning to delete for good. My intent is to then select-all and replicate those files to a temporary Group that I will name the same as the metadata field (and meta-data) I’m going to vaporize for good. Can this be accomplished first somehow?

Thanks again for being so helpful explaining this to me @pete31! …and for the script!

No problem over here. If you need help just ask. However I would suggest to keep the two threads separated to avoid confusing other users.

I think you’re complicating things a bit, in the end it’s quite simple:

  • Copy a meta data identifier you want to remove

  • In the main script: Paste in property deleteMetadataNames

  • Repeat until everything is set

  • Run the main script.

That’s it.

You could verify the main script’s result by running script 3 but that’s not necessary. You’re in the lucky position that I wrote, tested and ran the scripts on real data. They should work just fine for you too.


This Script: Remove some custom meta data should work.