Upload File and Email - Newbie

I am very new to Applescript, I will continue to look around these forums and try things for myself… but I thought I would post what I’m trying to accomplish. If you have any ideas, suggestions, or code to contribute I would appreciate it.

I need to create an Applet that I can drop files onto.

  1. When the file is dropped, it should prompt the user for their name.
  2. After that, prompt for any comments to add.
  3. Rename the file to the date (Jan 28 2006) + another word (Videocast) [filename: “Jan 28 2006 Videocast”]
  4. Move the file to a certain folder on the computer
  5. Upload the movie to a specified FTP location (using a favorites in Transmit)
  6. When the upload is complete, send an email (using an account in Mail) with the user name and comments in the body of the message. Or likewise send an error email if the file wasn’t uploaded.

Can anyone give me some hints, parts of scripts, or other help?

If you are an expert Applescripter and know how to do this, I am willing to pay someone to write it. Email me at tomgreever@communitychristian.org and we can discuss it.

Thanks!

Hi tom,

I currently have a working script that does exactly this.
I’ve also, at a previous job created the same script.
Here is the current script I am using…

display dialog "Would you like to email Final edits, FTP/Email final PDF, or send a Proof?" buttons {"Final edits", "FTP/Email final PDF", "Proof"} default button "Proof"

set ans to the button returned of the result

if the ans is "Proof" then
	set pdf to choose file with prompt "Please select the PDF to be emailed to the IHT..."
	set AppleScript's text item delimiters to ":"
	set mailsubj to (get last text item of (pdf as string)) as string
	tell application "Mail"
		set newmsg to make new outgoing message with properties {subject:"PDF " & (mailsubj) & " attached.", content:"Waiting for edits." & return & return & "Thank You." & return}
		tell newmsg
			make new to recipient at beginning of to recipients with properties {name:"IHT", address:"xxx@xxx.com"}
			set AppleScript's text item delimiters to ","
			set dayastext to get first text item of ((current date) as string)
			if dayastext is "Friday" then
				make new to recipient at beginning of to recipients with properties {address:"xxx@xxx.com"}
			end if
			set AppleScript's text item delimiters to ":"
			make new cc recipient at beginning of cc recipients with properties {name:"Bea", address:"xxx@xxx.net"}
			make new cc recipient at beginning of cc recipients with properties {name:"Anne", address:"xxx@xxx.net"}
			make new cc recipient at beginning of cc recipients with properties {name:"Anne", address:"xxx@xxx.net"}
			make new cc recipient at beginning of cc recipients with properties {name:"Phil", address:"xxx@xxx.net"}
			make new cc recipient at beginning of cc recipients with properties {name:"Dylan", address:"xxx@xxx.net"}
			set visible to true
			set sender to "xxx@xxx.net"
			make new attachment with properties {file name:pdf}
		end tell
		activate
	end tell
	
else if the ans is "FTP/Email final PDF" then
	set pdf to choose file with prompt "Please select the PDF to be emailed and uploaded to the IHT..."
	set AppleScript's text item delimiters to ":"
	set mailsubj to (get last text item of (pdf as string)) as string
	tell application "Mail"
		set newmsg to make new outgoing message with properties {subject:"FTP sent and " & (mailsubj) & " attached.", content:"Thank You." & return}
		tell newmsg
			make new to recipient at beginning of to recipients with properties {name:"IHT", address:"xxx@xxx.com"}
			set AppleScript's text item delimiters to ","
			set dayastext to get first text item of ((current date) as string)
			if dayastext is "Friday" then
				make new to recipient at beginning of to recipients with properties {address:"xxx@xxx.com"}
			end if
			set AppleScript's text item delimiters to ":"
			make new cc recipient at beginning of cc recipients with properties {name:"Bea", address:"xxx@xxx.net"}
			make new cc recipient at beginning of cc recipients with properties {name:"Anne", address:"xxx@xxx.net"}
			make new cc recipient at beginning of cc recipients with properties {name:"Anne", address:"xxx@xxx.net"}
			make new cc recipient at beginning of cc recipients with properties {name:"Phil", address:"xxx@xxx.net"}
			make new cc recipient at beginning of cc recipients with properties {name:"Dylan", address:"xxx@xxx.net"}
			set visible to true
			set sender to "xxx@xxx.net"
			make new attachment with properties {file name:pdf}
			tell application "Fetch"
				activate
				try
					close window "Fetch Transcript"
				end try
				
				try
					make new transfer window at beginning with properties {hostname:"xxx.xxx.com", username:"xxx", password:"xxx"}
				on error
					send to transfer window "xxx.xxx.com" ftp command {"user xxx@000.000.000.000", "PASS xxx"}
				end try
				
				
				duplicate pdf to remote item ":"
				
			end tell
			tell application "Mail"
				activate
			end tell
			
			
		end tell
	end tell
	
else if the ans is "Final edits" then
	set pdf to choose file with prompt "Please select the PDF to be emailed to the IHT..."
	set AppleScript's text item delimiters to ":"
	set mailsubj to (get last text item of (pdf as string)) as string
	tell application "Mail"
		set newmsg to make new outgoing message with properties {subject:"Edits to " & (mailsubj), content:"Waiting for final OK." & return & return & "Thank You." & return}
		tell newmsg
			make new to recipient at beginning of to recipients with properties {name:"xxx", address:"xxx.com"}
			set AppleScript's text item delimiters to ","
			set dayastext to get first text item of ((current date) as string)
			if dayastext is "Friday" then
				make new to recipient at beginning of to recipients with properties {address:"xxx@xxx.com"}
			end if
			set AppleScript's text item delimiters to ":"
			make new cc recipient at beginning of cc recipients with properties {name:"Bea", address:"xxx@xxx.net"}
			make new cc recipient at beginning of cc recipients with properties {name:"Anne", address:"xxx@xxx.net"}
			make new cc recipient at beginning of cc recipients with properties {name:"Anne", address:"xxx@xxx.net"}
			make new cc recipient at beginning of cc recipients with properties {name:"Phil", address:"xxx@xxx.net"}
			make new cc recipient at beginning of cc recipients with properties {name:"Dylan", address:"xxx@xxx.net"}
			set visible to true
			set sender to "xxx@xxx.net"
			make new attachment with properties {file name:pdf}
		end tell
		activate
	end tell
	
	
end if

This script gives a few options.
The purpose of it is to email proofs out of the work we do here. It can also email “final edits” and lastly, it can email a final proof to many different people, even on different days of the week it sends it to others, and then it uploads it to an FTP to be published.

I’ll gladly give you a hand writing this. No cash transaction is necessary. I enjoy doing it.

p.s. I’ve replaced any sensitive information in the script with “xxx”

In case you’re not subscribed to this topic, I’ll also email you.