I am trying to make a Applescript that imports the currently selected file in finder into the currently selected group in DevonThink. I am trying to do something similar to the script for importing mail from mail.app to the currently selected group. However, copy and paste (which that script uses) changes my file format. Importing works fine, though. I am setting a variable myFile to the current selection in Finder. Then, I switch to DevonkThink and use an import command with that variable. I use something like
import myFile to current group type all
and I get a message saying that the file does not match the type, which is strange since the type is all. Any help with this would be great. Thanks in advance.
Cameron
Just post the code of the script and I’ll check this.
With this code,
tell application “Finder”
activate
set myFile to the selection
end tell
tell application “DEVONthink Pro”
activate
import myFile to current group type all
end tell
I get this error
Can’t make «class docf» “Applescript and Scripting Resources @ MacScripter.pdf” of «class cfol» “Scans” of «class cfol» “cameron” of «class cfol» “Users” of «class sdsk» of application “Finder” into the expected type.
Thanks for your help.
Cameron
The Finder’s selection is an array containg 0-n items, therefore you have to a use a loop like this:
tell application "Finder"
set theSelection to the selection
repeat with theItem in theSelection
set theFile to POSIX path of (theItem as alias)
tell application "DEVONthink Pro" to import theFile
end repeat
end tell
Thank you for your assistance. This gets close to what I am attempting. The file now gets imported into DT. However, it only goes to the top of the database rather than to the particular folder selected inside the database, unlike the DT-included script for Mail, which moves the selected mail message into the selected subfolder.
Any further assistance would be much appreciated.
Cameron
Appending “to current group” to the “import” command should do this.
Fabulous! That did the trick. Thank you very much.
Cameron