Copy File to Mobileme and Create email message


Whilst Apple now allow you to send a link to a file to another user it requires the use of a web interface, I'm sure it will eventually be built into the Finder but until then this script helps to automate the process. This script is based on a idea from Drew McCormack
The first part of the script asks you to select a file, the next part uses a shell script to compresses it to a zip file if it is not already zipped. It then gets the mobileme name and then copies the zipped file to the Public folder of your mobilme (.dot mac) account. The final part of the script creates the email that you need to send to the intended recipient.
property mobileme_name : ""
property zip_file : "false"
property file_name : ""
property mobileme : ""
set theFile to (choose file with prompt "Select the file:") as text
try
	set text item delimiters to ":"
	set file_name to last text item of theFile
	set text item delimiters to ""
on error
	set text item delimiters to ""
end try

if theFile ends with "zip" then
	set zip_file to "true"
end if

if zip_file is "true" then
	--no need to compress
	set posix_path_theFile_zip to POSIX path of (theFile as text)
	
else if zip_file is "false" then
	--compress file first
	set posix_path_theFile to POSIX path of (theFile as text)
	
	set posix_path_theFile_zip to posix_path_theFile & ".zip"
	set file_name to file_name & ".zip"
	
	do shell script "zip -r -j " & posix_path_theFile_zip & " " & posix_path_theFile & ""
end if

tell application "Mail"
	--this assumes you have an mobileme email account
	--if you don't you will need to set the property  at the start of the script
	try
		set mobileme_name to name of every Mac account
	end try
	
end tell

set destination_posix to "/Volumes/" & mobileme_name & "/Public"

set destination_web to "http://idisk.mac.com/" & mobileme_name & "-Public/" & file_name

do shell script "cp " & posix_path_theFile_zip & " " & destination_posix

set zip_file to "false"



tell application "Mail"
	
	make new outgoing message with properties {visible:true, subject:"Link to File", content:"The file is here: " & destination_web}
	
end tell
You can download the script here