Updating one note's attribure value with the attribute value's of another note that has the same name

Here’s an AppleScript solution that may help. Lightly tested, but it seems to be doing the right thing. It also lists names of notes and attributes it couldn’t find in the container of imported notes, in case you want that to double-check those. Have the Tinderbox document open and frontmost, and run.

set oldContainer to "/Class Method 1b/"
set importContainer to "/Sample Assgn scores[].csv/"
set attribsToUpdate to {"A01", "A02", "A03", "A04", "A05"} -- do NOT use $ prefix here

set text item delimiters to ";" -- the Tinderbox separator for lists and sets
set doubleCheck to {} -- track possible update omissions

set tbCodeToListOldNoteNames to "collect(find(inside(" & oldContainer & ")),$Name)"
set tbCodeToListImpNoteNames to "collect(find(inside(" & importContainer & ")),$Name)"

tell front document of application "Tinderbox 8"
	
	set oldNotesAScrList to text items of (evaluate with tbCodeToListOldNoteNames)
	set impNotesAScrList to text items of (evaluate with tbCodeToListImpNoteNames)
	
	repeat with aNoteName in oldNotesAScrList
		
		-- the "it" refers to front document
		set oldNote to find note in it with path oldContainer & aNoteName
		set impNote to find note in it with path importContainer & aNoteName
		
		repeat with anAttrib in attribsToUpdate
			try
				set value of attribute anAttrib of oldNote to value of attribute anAttrib of impNote
			on error
				set end of doubleCheck to (aNoteName as text) & "-$" & (anAttrib as text)
			end try
		end repeat
		
	end repeat
	
	repeat with aName in impNotesAScrList
		tell aName to if it is not in oldNotesAScrList then set end of doubleCheck to (it as text) & "-imp"
	end repeat
	
	display dialog "Doublecheck: " & (doubleCheck as text)
	
end tell

EDIT - added error check for imported notes that are not in container of old notes

2 Likes