# Tips: Insert video into markdown notes

**URL:** <https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717>\
**Category:** DEVONthink\
**Tags:** automation, devonthink3\
**Created:** [October 5, 2020, 3:22pm UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717 "2020-10-05T15:22:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fu.nyanderful](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/f/3bc359/32.png) [@Fu.nyanderful](https://discourse.devontechnologies.com/u/Fu.nyanderful)\
**Post date:** [October 5, 2020, 3:22pm UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/1 "2020-10-05T15:22:17Z")

</div>

Hi there~

It seems that no one in the community has shared the content about how to insert audio and video into Markdown notes?? 🤔 I searched for the keyword “markdown” and “video”, but I didn’t find the relevant content…

Recently I found a method of inserting online video into markdown file on the Internet. After testing, it is still available after replacing the network address of the video with the DT file link.

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/3/3/330bf811ba86d187cd7c6c85df3eb6f696758e1e.png)  
Insert the file link of the cover in position 1  
Insert the file link of the video at position 2  
and then:

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/8/1/815513a0063a1ae01b9ab8606e501b4430ecaf6d.jpeg)

Maybe this is the basics of markdown syntax and I don’t know if I’m the only one who just learned about this. 😝 For me this is quite useful, I like to insert some videos in the notes of life record.

So if you already know this method, two small questions for you:

1. Can anyone write a script to generate a video markdown link?
2. If I insert a photo into Markdown, then the width and height of the photo can be changed according to the size of my editing window, but if I insert a video, it does not work, I wonder if this can be set?

---

<div class="post-metadata">

**Author:** ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)\
**Post date:** [October 5, 2020, 3:49pm UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/2 "2020-10-05T15:49:04Z")

</div>

> [@Fu.nyanderful](#):
>
> Maybe this is the basics of markdown syntax

It’s the basic of HTML syntax (HTML5, I think). It has nothing to do with Markdown as such. MD just accepts HTML elements and some of the MD processors might even honor `<video>` etc. Personally, I wouldn’t rely on it. But then I don’t need video anyway.

> [@Fu.nyanderful](#):
>
> Can anyone write a script to generate a video markdown link?

As @pete31 said in the other thread: you should learn AppleScript (or JavaScript, or both) and write your own scripts.  
I might add: Or pay someone who does it for you.

> [@Fu.nyanderful](#):
>
> If I insert a photo into Markdown, then the width and height of the photo can be changed according to the size of my editing window, but if I insert a video, it does not work, I wonder if this can be set?

As I said before, this is HTML syntax. It has nothing to do with DEVONthink not Markdown. HTML is explained over at Mozilla developer network (MDN) and a lot of other places in the web.

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [October 5, 2020, 4:11pm UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/3 "2020-10-05T16:11:22Z")

</div>

Here is a _teaching edition_ example of creating the HTML links…

```auto
tell application id "DNtp"
	set URLList to {} -- Start an empty list
	
	repeat with thisRecord in (selection as list) -- Loop through the selected items.
		set recordType to (type of thisRecord as string) -- Put the type of the record into a variable
		if (recordType = "quicktime") then -- Check if the record type is video (or audio actually)
			set recordLink to (reference URL of thisRecord as string) -- Put the item link in a variable
			copy ¬
				("<video controls=\"\"> <source src=\"" & recordLink & "\"></video> " & return) to end of URLList
			-- Construct the HTML link, including the item link and copy it to variable for the list of URLs 
			-- Note double quotes have to be escaped. Otherwise they would close a quoted section of text.
		end if
	end repeat
	
	if URLList ≠ {} then -- Check the variable for the list of URLs. If it's not empty copy the list as a string to the clipboard.
		set the clipboard to (URLList as string)
	end if
end tell

```

And you can add CSS styling for the `video` element to adjust it’s dimensions, e.g.,…

```auto
video {
width: 95vw;
height: auto;
margin: 10px 0;
}

```

---

<div class="post-metadata">

**Author:** ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)\
**Post date:** [October 5, 2020, 4:26pm UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/4 "2020-10-05T16:26:43Z")

</div>

> [@BLUEFROG](#):
>
> `set recordLink to (reference URL of therecord as string)`

Shouldn’t that be `thisRecord` instead of `therecord`?

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [October 5, 2020, 7:02pm UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/5 "2020-10-05T19:02:26Z")

</div>

Yep. Thanks.  
I was modifying it to show another basic step and variable use.

Fixed.

---

<div class="post-metadata">

**Author:** ![Fu.nyanderful](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/f/3bc359/32.png) [@Fu.nyanderful](https://discourse.devontechnologies.com/u/Fu.nyanderful)\
**Post date:** [October 6, 2020, 2:18am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/6 "2020-10-06T02:18:07Z")

</div>

Thanks for your reminder, I’ll start learning about them. Apologize for my rudeness and ignorance. 😭

---

<div class="post-metadata">

**Author:** ![Fu.nyanderful](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/f/3bc359/32.png) [@Fu.nyanderful](https://discourse.devontechnologies.com/u/Fu.nyanderful)\
**Post date:** [October 6, 2020, 2:21am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/7 "2020-10-06T02:21:50Z")

</div>

Thank you so much!! For your help and patience!!!

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [October 6, 2020, 2:24am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/8 "2020-10-06T02:24:06Z")

</div>

No worries!  
Check out the Automation chapter in the Help. It covers more than just AppleScript.

Start with something simple like showing a dialog box to enter a name that will create a group with that name.

Also, I often use the term _”teaching edition”_ in scripts for the forums. The scripts in the posts are written in a simpler, beginner fashion and usually commented so explain some of what’s happening.

And remember, automation is not the answer to everything.

---

<div class="post-metadata">

**Author:** ![Fu.nyanderful](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/f/3bc359/32.png) [@Fu.nyanderful](https://discourse.devontechnologies.com/u/Fu.nyanderful)\
**Post date:** [October 6, 2020, 2:41am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/9 "2020-10-06T02:41:19Z")

</div>

In fact, I’m reading dt’s help manual and trying to learn AppleScript, but due to some language and knowledge barriers, the pace of learning is a little out of keeping pace with my needs… 🙈 Dt is really a software with unlimited possibilities, this community also brings me a lot of help, so trust me, I do not want to cause trouble for everyone, if I have something wrong please tell me straight.

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [October 6, 2020, 4:38am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/10 "2020-10-06T04:38:17Z")

</div>

Start small and simple, like the example I mentioned.  
Like any language, it takes time to get used to. However, it’s still not out of reach for beginning coders.

And don’t forget there are things that can be done with smart rules and **Tools \> Batch Process**.

---

<div class="post-metadata">

**Author:** ![Fu.nyanderful](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/f/3bc359/32.png) [@Fu.nyanderful](https://discourse.devontechnologies.com/u/Fu.nyanderful)\
**Post date:** [October 6, 2020, 4:49am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/11 "2020-10-06T04:49:33Z")

</div>

Okay, thank you for your patient answers 🌹

---

<div class="post-metadata">

**Author:** ![BLUEFROG](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/bluefrog/32/135_2.png) [@BLUEFROG](https://discourse.devontechnologies.com/u/BLUEFROG)\
**Post date:** [October 6, 2020, 5:05am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/12 "2020-10-06T05:05:25Z")

</div>

You’re welcome 🙂

---

<div class="post-metadata">

**Author:** ![Fu.nyanderful](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/f/3bc359/32.png) [@Fu.nyanderful](https://discourse.devontechnologies.com/u/Fu.nyanderful)\
**Post date:** [October 6, 2020, 5:46am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/13 "2020-10-06T05:46:34Z")

</div>

Ahh sorry for the last question 😓, is “Quicktime” a type that includes video and audio?

If I want to create a link for audio file, like this `<audio controls=""> <source src="XXX"></audio>` and for video file, like this`<video controls=""> <source src="XXX"></video> `

How should i distinguish it

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/c/f/cf5fa551f7bb4a33cda123dbbeb1dbe775e0f604.png)

---

<div class="post-metadata">

**Author:** ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)\
**Post date:** [October 6, 2020, 6:20am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/14 "2020-10-06T06:20:52Z")

</div>

I don’t see a way. QuickTime is (was?) Apple’s media player/streaming server concoction. Since DT offers only this type (which I think is a misnomer), it probably does not differentiate between video and audio. You could try using the file extension or the command line tool `file`.

---

<div class="post-metadata">

**Author:** ![Fu.nyanderful](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/f/3bc359/32.png) [@Fu.nyanderful](https://discourse.devontechnologies.com/u/Fu.nyanderful)\
**Post date:** [October 6, 2020, 7:24am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/15 "2020-10-06T07:24:10Z")

</div>

Thank you for your guidance. I tried to write a version based on @BLUEFROG that can distinguish pictures, videos, and audios. Maybe most of you can write such a simple script, but I still share it here, I hope it will be useful to someone. 😛

```auto
tell application id "DNtp"
	set URLList to {}	
	repeat with thisRecord in (selection as list)
		set recordName to (name of thisRecord as string)
		set recordType to (type of thisRecord as string)
		set recordKind to (kind of thisRecord as string)
		set recordLink to (reference URL of thisRecord as string)
		if (recordType = "quicktime") then
			if (recordKind = "MPEG-4 movie") or (recordKind = "QuickTime movie") then
				copy ¬
					("* [" & recordName & "](" & recordLink & ")" & return & return & space & space & space & space & "<video controls=\"\"> <source src=\"" & recordLink & "\"></video> " & return & return) to end of URLList
			else if (recordKind = "MP3 audio") then
				copy ¬
					("* [" & recordName & "](" & recordLink & ")" & return & return & space & space & space & space & "<audio controls=\"\"> <source src=\"" & recordLink & "\"></audio> " & return & return) to end of URLList
			end if
		else if (recordType = "Picture") then
			copy ¬
				("* [" & recordName & "](" & recordLink & ")" & return & return & space & space & space & space & "![](" & recordLink & ")" & return & return) to end of URLList
		else
			copy ¬
				("* [" & recordName & "](" & recordLink & ")" & return & return) to end of URLList
		end if
	end repeat
	
	if URLList ≠ {} then
		set the clipboard to (URLList as string)
	end if
end tell

```

---

<div class="post-metadata">

**Author:** ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)\
**Post date:** [October 6, 2020, 9:24am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/16 "2020-10-06T09:24:40Z")

</div>

One note auf caution: recordKind could depend on the locale. So it might well be “MPEG-4 Film” on someone’s Mac running in the German locale.

---

<div class="post-metadata">

**Author:** ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)\
**Post date:** [October 6, 2020, 9:25am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/17 "2020-10-06T09:25:13Z")

</div>

Here’s a minor revision which does not depend on the version of macOS/Finder or the localization:

```auto
tell application id "DNtp"
	set URLList to {}
	
	repeat with thisRecord in (selection as list)
		set recordName to (name of thisRecord as string)
		set recordType to type of thisRecord
		set recordLink to (reference URL of thisRecord as string)
		if recordType as string is "quicktime" or recordType as string is "«constant **** quti»" then
			if width of thisRecord is greater than 0 and height of thisRecord is greater than 0 then
				copy ("* [" & recordName & "](" & recordLink & ")" & return & return & space & space & space & space & "<video controls=\"\"> <source src=\"" & recordLink & "\"></video> " & return & return) to end of URLList
			else
				copy ("* [" & recordName & "](" & recordLink & ")" & return & return & space & space & space & space & "<audio controls=\"\"> <source src=\"" & recordLink & "\"></audio> " & return & return) to end of URLList
			end if
		else if recordType is picture then
			copy ("* [" & recordName & "](" & recordLink & ")" & return & return & space & space & space & space & "![](" & recordLink & ")" & return & return) to end of URLList
		else
			copy ("* [" & recordName & "](" & recordLink & ")" & return & return) to end of URLList
		end if
	end repeat
	
	if URLList ≠ {} then
		set the clipboard to (URLList as string)
	else
		display alert "No items selected."
	end if
end tell
```

---

<div class="post-metadata">

**Author:** ![Fu.nyanderful](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/f/3bc359/32.png) [@Fu.nyanderful](https://discourse.devontechnologies.com/u/Fu.nyanderful)\
**Post date:** [October 6, 2020, 10:03am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/19 "2020-10-06T10:03:18Z")

</div>

Thank you so much, I just wanted to say that after I moved the script I wrote from the Menu folder to the Toolbar folder, it couldn’t be used… 😓

But the strange thing is that when I execute the script you wrote for audio files and video files, The link on the clipboard doesn’t seem to be complete (Picture link can be obtained normally). Like this…

 ![image](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/f/b/fb1218afdfe55965812884cd6f18a15a5f72cdd2.jpeg)

What is even more strange is I execute the script @BLUEFROG wrote for video files, The clipboard does not seem to be able to get the link successfully…Do you know why is that? 😓

---

<div class="post-metadata">

**Author:** ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)\
**Post date:** [October 6, 2020, 11:32am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/20 "2020-10-06T11:32:29Z")

</div>

> [@Fu.nyanderful](#):
>
> I moved the script I wrote from the Menu folder to the Toolbar folder, it couldn’t be used… 😓

It doesn’t make a difference whether it’s in the menu or toolbar over here, the conversion of the type to a string fails. The mysteries of AppleScript 🤔

---

<div class="post-metadata">

**Author:** ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)\
**Post date:** [October 6, 2020, 11:39am UTC](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717/21 "2020-10-06T11:39:20Z")

</div>

A workaround might look like this:

```auto
if recordType as string is "quicktime" or recordType as string is "«constant **** quti»" then
```

[Next page](https://discourse.devontechnologies.com/t/tips-insert-video-into-markdown-notes/58717.md?page=2)
