Hi!
I have get a working script before to copy tags from a movie file to a screenthumb file.
For example:
file1.mp4 → file1_screencaps.jpg
file2.avi → file2_screencaps.jpg and so on…
Today I use more file1.mp4 → file1.jpg
file2.wmv → file2.jpg and so on.
This script doesn’t work anymore for me or need to be adjusted I think:
-- Copy tags from movies to screen captures
property pExtensions : {".avi", ".mp4", ".mov", ".mpg", ".mpeg", ".wmv", ".rm"}
property pSuffix : ".jpg"
tell application "DEVONthink 3"
set theSelection to the selection
repeat with theRecord in theSelection
set theName to name of theRecord
repeat with theExtension in pExtensions
if theName ends with theExtension then
set extensionLen to length of theExtension
-- Works only as long as the name doesn't contain / which should be replaced with \/ in locations
set theLocation to location of theRecord & (characters 1 thru -(extensionLen + 1)) of theName & pSuffix
set theDatabase to database of theRecord
set theOtherRecord to get record at theLocation in theDatabase
if exists theOtherRecord then set tags of theOtherRecord to tags of theRecord
end if
end repeat
end repeat
end tell
I get the following result from movie.wmv with the thumbnail file movie.jpg:
tell application "DEVONthink 3"
get selection
--> {content id 33431 of database id 1, content id 33443 of database id 1}
get name of content id 33431 of database id 1
--> "Movie"
get name of content id 33443 of database id 1
--> "Movie"
end tell
It seems like the tags section doesn’t do anything in the script?
that returns the name of the record without its extension (in my experimenting even if Show filename extensions is set in the preferences); I suspect that may once have been otherwise, as the dictionary contains a name without extension variable.
If you use path of theRecord the extension will be at the end of the variable as expected, so try this:
-- Copy tags from movies to screen captures
property pExtensions : {".avi", ".mp4", ".mov", ".mpg", ".mpeg", ".wmv", ".rm"}
property pSuffix : ".jpg"
tell application "DEVONthink 3"
set theSelection to the selection
repeat with theRecord in theSelection
set theName to name of theRecord
set thePath to path of theRecord
repeat with theExtension in pExtensions
if thePath ends with theExtension then
set extensionLen to length of theExtension
-- Works only as long as the name doesn't contain / which should be replaced with \/ in locations
set theLocation to location of theRecord & name of theRecord & pSuffix
set theDatabase to database of theRecord
set theOtherRecord to get record at theLocation in theDatabase
if exists theOtherRecord then set tags of theOtherRecord to tags of theRecord
end if
end repeat
end repeat
end tell
If in doubt, use name without extension where I have used name just in case things change in the future.
check that the extension of your jpegs really is .jpg and not .jpeg
Edit: ah, stop: I changed the script moments after posting it and after having tested it; pls use the current version posted above; you copied it before I had made the change (sorry about that!)
I had omitted to change the line which removed the extension from the name (that removal, of course, isn’t necessary because the name doesn’t contain the extension).
So this
set theLocation to location of theRecord & (characters 1 thru -(extensionLen + 1)) of theName & pSuffix
became this:
set theLocation to location of theRecord & name of theRecord & pSuffix
@cgrunenberg: with regards record, both name and name without extension return the same value; is that intentional? (I see you wrote the original script approx. 2012, so for DT2 - I guess the behaviour changed with DT3)