Sure
this line add custom meta data "" for "test" to theRecord
is the one which actually overwrites the custom metadata; so simply adding another such line will make the script handle two custom metadata fields. Of course each line needs to point to the appropriate identifier. Rather than do that, however, we can make the script go round and round in circles until it has handled a whole list of identifiers which you supply; that routine is included in the script below.
If you are going to use the script on any kind of regular basis, it should be expanded to do three more things; first, to give you notice if you forget to actually select any records; second to only replace the custom metadata if there actually is currently any metadata in the appropriate field; and third to trap any errors.
The first is done by adding if theRecords = {} then error "Please select some records."
The second is done by adding an if custom metadata in question isn't empty
routine.
The third is done by adding a try
routine with an on error
section.
The end result looks like this (and is taken, in part, from this post by @bluefrog (no point in reinventing the wheel); the error handling is copied from @pete31.
# Mark only the records for which the defined custom metadata should be removed
# CHANGES MADE BY SCRIPTS CANNOT BE UNDONE
# In the following line of code (starting with: property), between the {} add the identifiers of metadata to be removed. Each identifier needs to be enclosed in " and identifiers should be separated by a comma, e.g. {"test", "another", "etc"}.
# The appropriate identifier can be found in DEVONthink > Preferences > Data, by highlighting the metadata in question; the identifier will then be shown in the top righthand half of the Preferences window.
property attributesToScrub : {}
tell application id "DNtp"
try
set theRecords to selection
if theRecords = {} then error "Please select some records."
if attributesToScrub = {} then error "Please add identifiers to the Property \"attributesToScrub\" in the Script"
repeat with theRecord in theRecords
repeat with thisAttribute in attributesToScrub
set mdQuery to (get custom meta data for thisAttribute from theRecord)
if mdQuery ≠ missing value then
add custom meta data "" for thisAttribute to theRecord
end if
end repeat
end repeat
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
return
end try
end tell
And for the last trick: Scripts can be included in the toolbar in DEVONthink; this is explained on pp 197, 198 of the current DEVONthink 3.8 Documentation.