Automatic / programmatic creation of file from image and content of its (custom) data field(s)?

And a basic working code snippet you could work with…

tell application id "DNtp"
	if (selected records) is {} then return
	repeat with theRecord in (selected records)
		set {recName, recLink} to {name without extension, reference URL} of theRecord
		if (type of theRecord) is picture then
			set theLink to "![](" & recLink & ")" as string -- Image Link
		else
			set theLink to "{{" & recName & "}}" as string -- Transclusion
		end if
		
		set theCategory to get custom meta data for "Category" from theRecord
		set theCompany to get custom meta data for "Company" from theRecord
		set theLoc to get custom meta data for "Last Locations" from theRecord
		
		set theText to "# " & recName & linefeed & linefeed & theLink & linefeed & linefeed & "## " & theCompany & linefeed & linefeed & theCategory & ". " & theLoc
		
		set newDoc to create record with {name:recName, type:markdown, content:theText} in current group
	end repeat
end tell
1 Like