Copy Thumbnail image to moviefile with script (Solved)

I have search a long time for a solution to generate unique video thumbnails for eg. more better duplicate searching in DT.
Becuase DT just go after the thumbnails when it search for duplicates.
I have now a little script request.

The DT team have developed the application Thumbsup some years ago and I think this is the application who can solve this duplicate thumbnail problem especially when the program generate a thumbnail in the middle of the movieclip instead for the beginning.

If I generate jpeg files for every movie file I got. The only thing I want now is to copy this thumbnails from the jpeg files and to the videoclips with the same name like movie1.wmv for the videoclip and movie1_thumb.jpg for the generated jpeg file.

Why not have a option in DT to generate a video thumbnail in the middle of the movie instead for the beginning?
I think this would be the best and most easy thing to do to solve this false alarm video duplicate problem.

Thank you very much in advanced for helping me with this scipt!


It’s possible to set the “thumbnail” property to a path. See Scripts > Thumbnails for example.

Usually DEVONthink uses the middle (but not later than 15 seconds). Depending on the video format, using the middle could be very slow otherwise.

Thanks for the reply Christian!
It would be great if you can give me the script for creating thumbnails then you right click on a movie file and can choose Thumbnails -> Create/Update/Remove :slight_smile:

I think I can solve this myself if I can get some template how this is made for thumbnail creating…

Thanks in advanced!

There’s no such script but the “create/update/remove thubmnail” commands do exactly this. And the contextual(action menu contains these commands too, therefore I’m not sure what’s your goal.

It is these commands I want to know. I mean my goal is to create a script that helps me to create a thumbnail (like the command for create/update thumbnail) and want to modify this script so I can choose where in the movieclip I want to create the thumbnail, like after 30 seconds.

I can take the risk if it go little slower to create this thumbnails. It goes much faster to do this than to copy the image thumbnail from the file I get from Thumbsup and replace the movie thumbnail from the movieclip with this new thumbnail.

I hope you understand now how I mean Christian why I need a script for the creation of the movieclip thumbnail :wink:

That’s not possible, the script commands work exactly the same way the internal commands work.

So you mean it’s not a applescript that create this thumbnails and if I have understand you right, you mean the thumbnail creating process for the duration of the clip is unscriptable and the command for update thumbnail is with help from some sort of an internal framework/function that you can’t modify with help from an applescript, right?

I’m sorry if I nagging on you, that is not my purpose. I just hope to find some solution for this :smiley:

More or less right :wink:

Ok, now I’m with you.
So the only thing I can do right now that I know is scriptable but I’m not so used to write script so I really appreciate if you could help me to write this script.

The goal is to replace the thumbnail to movie.avi from movthumb_movie.jpg (that I create the movthumb_movie.jpg from your Thumbsup application)

This is the only thing I need help with to do what I’m searching after with this thread and I’m sure many other users could get help from this script too.

Did you have a look at Scripts > Thumbnails and their sources?


Is it the scripts in Devonthink you mean or is it some script collection on the Devonthink site I should look at?

See menu Scripts > Thumbnails > … or the folder ~/Library/Application Support/DEVONthink Pro 2/Scripts/Thumbnails.

I have looking through this scripts before. But it’s only for processing image file properties and I don’t know how to use this scriptfiles to use for replacing a movie clip thumbnail.

It would be very helpful if you could write some example code how this script can be made, just to be a start so I can get an idea how this could be done.

You can set the thumbnail property to a path (like the thumbnail scripts do):

set the thumbnail of myRecord to “/Users/myAccount/Pictures/myPicture.jpg”

ok, but as you know, it isn’t only one file I want to do this with.
I have more than 1000 files that I need to replace the thumbnail picture on, so I need som variable for this.

For example:
applescript-ipod.m4v (movieclip) - movthumb_applescript-ipod.jpg
managing-ipod.m4v (movieclip) - movthumb_managing-ipod.jpg
managing-imac.m4v (movieclip) - movthumb_managing-imac.jpg
and so on…

So my goal is to for this example select all this 6 files in DT and use this script to get the correct thumbnail picture from the movthumb jpg file to the same name with some other suffix like avi, m4v or something else.

I think this script I found from one of the scriptfiles could be useful for what I need help with but needs of course to be modified for the replacement of the movie thumbnail.

 tell application id "com.devon-technologies.thinkpro2"
		set this_selection to the selection
		if this_selection is {} then error "Please select some contents."
		repeat with this_item in this_selection
			if exists thumbnail of this_item then
					set this_thumb to thumbnail of this_item
					set this_path to my writeData(this_thumb)
					with timeout of 30 seconds
						tell application "Image Events"
							close this_file saving yes
						end tell
					end timeout
					set the thumbnail of this_item to this_path
				end try
			end if
		end repeat
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell

on writeData(theData)
	local theFileRef, thePath
	set thePath to POSIX path of (path to temporary items from user domain)
	set thePath to thePath & "/_DEVONthink_Pro_thumbnail_.tiff"
	set theFileRef to open for access POSIX file thePath with write permission
	set eof of theFileRef to 0
	write theData to theFileRef
	close access theFileRef
	return thePath
end writeData

My knowledge to write applescript is to limited today for me to finish this script at myself, so that’s why I really appreciate all help I can get to solve this.

Here’s a basic script. The extension of the files has to contain exactly 3 characters (e.g. m4v) and the thumbnails have to be in the same directory as the movies, therefore it’s probably only useful for indexed files.

tell application id "com.devon-technologies.thinkpro2"
	set theSelection to the selection
	repeat with theRecord in theSelection
		set thePath to path of theRecord
		set thePath to ((characters 1 thru -4 of thePath) as string) & "jpg"
		set thumbnail of theRecord to thePath
	end repeat
end tell

I try this script for some minute ago, but for me it doesn’t work.
I have the thumbnail in the same directory as the moviefile like:
Apple March 6 Event_ iPhone Software.m4v
Apple March 6 Event_ iPhone Software_movthumb.jpg

And tag both indexed files with the same tag and select this both files and run the script and nothing happens…

Have I done something wrong and need to use this script on another way for this to work?

Edit: I select the files in devonthink and run the script from the script editor so I could see in the eventlog what happens and saw what the problem is and have solve this.

The problem was that the script search for the name
Apple March 6 Event_ iPhone Software.movthumb.jpg
but the created file had the name Apple March 6 Event_ iPhone Software_movthumb.jpg and therefore the script couldn’t find the correct name of the file.

I also changed the script slightly with one little change to this:

tell application id "com.devon-technologies.thinkpro2"
	set theSelection to the selection
	repeat with theRecord in theSelection
		set thePath to path of theRecord
		set thePath to ((characters 1 thru -4 of thePath) as string) & "movthumb.jpg"
		set thumbnail of theRecord to thePath
	end repeat
end tell

After I changed this file suffix from _movthumb.jpg to .movthumb.jpg in Thumbsup, the script works perfectly

Thank you very much for the help of doing this script Christian!