Quick Newbie Question

I’ve just got a quick question here, how do I get just the visible name of a folder in finder?
The script I’ve worked out already is

choose folder with prompt “Choose a folder:”

set foldername to result

tell application “Mail”
set new_message to make new outgoing message with properties {subject:foldername, visible:true}
end tell

Which is intended to create a new email with the subject being the name of the chosen folder, however, the resulting subject is something more like “/Users/me/Documents/folder1/goal” whereas I would like it to just be “goal”.
I’m sure the solution is very simple but I’ve had very little experience with applescript before. Any help at all would be greatly appreciated.



Try this,

tell application "Finder"
	set folderChosen to choose folder with prompt "Choose your folder."
	set foldName to name of folder folderChosen
display dialog folderChosen as string
end tell


Works a charm, thank you very much!