how to get the path to a group

Hi,
i try to save files into DTO with an Apple Script but i have trouble to get the path to a group selected with the “display group selector”:

set theGroup to display group selector
set theGroupPath to path of theGroup
set thePath to theGroupPath & theAttachmentName 
save theAttachment in thePath

I only get empty strings ?

Event protocol:

tell application "DEVONthink Pro"
	display group selector
		--> parent id 110144 of database 1
	get path of parent id 110144 of database 1
		--> ""
end tell

i’m missing something?

Ok, i had a look at the properties of a group-record,and “path” might not what i’m looking for (it’s really empty for groups). I will try a bit with the “location”-property.

The path is only available for indexed/external folders whereas the “save” command is only supported by windows. But what you’re looking for might be the “import” command.

yes, import does the job :slight_smile:

so here is my (poorly coded :unamused: ) Applescript to import attachments from selected mails in Apple Mail.For the moment I still like to have some control on where my files are stored :slight_smile:
So i used “display group selector” to get the group to store the files.
It works for me (on 10.6.2), but i think there should be some more error-handling!

-- import any attachment of selected messages in Apple Mail to a selected group
-- J. Scholtes 
-- Version 0.0.0.0.0.0.0.0.1 ;)

-- get the default path where Mail stores downloaded attachments
-- normaly is this ~/Library/Mail Downloads
property defaultMailAttachmentPath : ""
tell application "Finder"
  set userHomePath to (path to home folder as text)
  set defaultMailAttachmentPath to userHomePath & "Library:Mail Downloads:"
end tell

tell application "Mail"
	try
		-- check if database is open
		tell application id "com.devon-technologies.thinkpro2"
			if not (exists current database) then error "No database is in use."
		end tell
		-- get selected messages
		set theSelection to the selection
		if the length of theSelection is less than 1 then error "One or more messages must be selected."
		
		-- get the Group where the attachment should go
		tell application id "com.devon-technologies.thinkpro2"
			set theGroup to display group selector
		end tell
		
		-- run through the messages
		repeat with theMessage in theSelection
			my importMessage(theMessage, theGroup)
		end repeat
	on error error_message number error_number
		if error_number is not -128 then display alert "Mail" message error_message as warning
	end try
end tell

on importMessage(theMessage, theGroup)
	tell application "Mail"
		try
			set theAttCount to count of mail attachments of theMessage
			-- if we have attachments 
			if theAttCount is greater than 0 then
				-- run through the attachments
				repeat with a from 1 to (count of mail attachments of theMessage)
					
					-- get some info of the attachment
					set theAttachment to mail attachment a of theMessage
					set theAttachmentName to name of (mail attachment a of theMessage)
					set theDateSent to the date sent of theMessage
					set theSender to the sender of theMessage
					set theSubject to subject of theMessage
					if theSubject is equal to "" then set theSubject to "no Subject"
					set theSource to the content of theMessage
					set theReadFlag to the read status of theMessage
					
					tell application id "com.devon-technologies.thinkpro2"
						
						-- where should I finde the attachment?
						set thePath to defaultMailAttachmentPath & theAttachmentName
						-- check if it is already downloaded by Apple Mail
						tell application "Finder"
							set fileExists to exists file thePath
						end tell
						if (fileExists) then
							-- if we find it -> import to DT
							set theRecord to import thePath name theAttachmentName to theGroup
						else
							-- if not -> save it first in the default path
							save theAttachment in thePath
							set theRecord to import thePath name theAttachmentName to theGroup
						end if
						
						-- set some details for the new record
						set unread of theRecord to (not theReadFlag)
						set date of theRecord to theDateSent
						-- sometimes the message text as usefull info -> store it as comment
						set comment of theRecord to theSource
						-- sometimes it is usefull to now where it came from
						set URL of theRecord to theSender
						
					end tell
				end repeat
			end if
		on error error_message number error_number
			if error_number is not -128 then display alert "Mail" message error_message as warning
		end try
	end tell
end importMessage


regards
Jürgen