(Auto) Remove Images from formatted note

I love the formatted note which is captured by DTPro

  • how to remove images after the notes are captured ,besides manually deletion
  • capture as formatted note but without images

Neither of these of possible as this time.
May I ask why you’d want these options?

Thank you for quick response.

I love how a formatted note looks, readability is awesome with it .

The idea to remove the images from the note was to reduce the note size which often is >500 KB due to 3-4 images generally on a good article.

You’re welcome and that is true. A formatted note can quickly become large with the embedded image data.

Development would have to assess the request to capture a formatted note without images.

Pick a file, duplicate it, and run this code in Script Editor…

tell application id "DNtp"
	repeat with thisRecord in (selected records)
		do shell script "sed -i '' 's_<img .*\\\">__g' " & quoted form of (path of thisRecord as string)
	end repeat
end tell

Does that work as expected?

This works absolutely fine. Thank you !!

This would be great too

You’re welcome.

Here’s a slightly error-trapped version…

tell application id "DNtp"
	repeat with thisRecord in (selected records)
		if (type of thisRecord) is formatted note then
			do shell script "sed -i '' 's_<img .*\\\">__g' " & quoted form of (path of thisRecord as string)
			update thumbnail of thisRecord
		end if
	end repeat
end tell

A slightly safer RE would be
<img[^>]+>
Using a non-greedy expression that doesn’t gobble up more than absolutely necessary.
Imagine you had a img and an a element in the same line/paragraph – I think your expression would eat the a element, too.

Indeed.
's_<img[^>]*>__g' works.