Count files and email total

I use the following script to ftp photos, and then email family members to notify them of the new additions. I would like to add in the body of the email, the number of new photos added.


(* FTPupload is an Action Folder script to silently upload to an FTP server the files/folders added to a folder. It requires NcFTP, a free program you can download here: <http://www.ncftp.com/download/>. I decided to use NcFTP instead of the built-in FTP command, because NcFTP can upload whole folders. You have to set your personal FTP parameters at the top of the script. *)
-- Author: Fabrizio Costantini thefabmac@users.sourceforge.net
property theUserid : "username"
property thePassword : "pass"
property theServer : "domain.com" -- e.g. "[url=ftp://ftp.apple.com]ftp.apple.com[/url]"
property theRemotePath : "/public_html -- mandatory: use "/" for root directory

on adding folder items to this_folder after receiving these_items
	tell application (path to frontmost application as text) to display dialog "going to send email..."
	tell application "Finder"
		set thePath to quoted form of POSIX path of (this_folder as alias)
		set theFiles to ""
		repeat with theItem in these_items
			set theFiles to theFiles & "\"" & (name of theItem as text) & "\" "
		end repeat
		do shell script "cd " & thePath & "; ncftpput -R -u " & theUserid & " -p " & thePassword & " " & theServer & " " & theRemotePath & " " & theFiles
		
	end tell
	
	try
		tell application "Mail"
			activate
			set theSender to "ryan@domain.org" (*Set this email address to the account Mail is using.*)
			set theSubject to "New Pix added" (*Change the subject to what you like/need.*)
			set theHost to "mac" (*Set this to the computer this is running on - helpful if you have multiple machines.*)
			set theAddress to "user@gmail.com, user@hotmail.com" (*Set this email address to where you want the notification delivered.*)
			set thebody to "This e-mail is to inform you that new pictures have been added to family website. Come check them out! http://www.domain.com" (*This is the body of the email-adjust as you like.*)
			set newMessage to make new outgoing message with properties {subject:theSubject, content:thebody, sender:theSender, address:theAddress}
			tell newMessage	
				make new to recipient with properties {address:theAddress}	
			end tell
			send newMessage
		end tell
		
	on error msg
		tell application (path to frontmost application as text) to display dialog "ERROR:" & return & return & msg
	end try
	tell application (path to frontmost application as text) to display dialog "email sent..."
	
end adding folder items to

The body would read something like: “This e-mail is to inform you that (15) new pictures have been added to family website. Come check them out! http://www.domain.com

Hope you can help,
Ryan

Model: PPC Mac Mini
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Hello

If I understood correctly the question you just need two changes:


(* FTPupload is an Action Folder script to silently upload to an FTP server the files/folders added to a folder. It requires NcFTP, a free program you can download here: <http://www.ncftp.com/download/>. I decided to use NcFTP instead of the built-in FTP command, because NcFTP can upload whole folders. You have to set your personal FTP parameters at the top of the script. *)
-- Author: Fabrizio Costantini thefabmac@users.sourceforge.net
property theUserid : "username"
property thePassword : "pass"
property theServer : "domain.com" -- e.g. "[url=ftp://ftp.apple.com]ftp.apple.com[/url]"
property theRemotePath : "/public_html -- mandatory:" --use "/" for root directory

on adding folder items to this_folder after receiving these_items
	tell application (path to frontmost application as text) to display dialog "going to send email..."
	tell application "Finder"
		set thePath to quoted form of POSIX path of (this_folder as alias)
		set theFiles to ""
		set knt to count of these_items -- ADDED
		repeat with theItem in these_items
			set theFiles to theFiles & "\"" & (name of theItem as text) & "\" "
		end repeat
		do shell script "cd " & thePath & "; ncftpput -R -u " & theUserid & " -p " & thePassword & " " & theServer & " " & theRemotePath & " " & theFiles
		
	end tell
	
	try
		tell application "Mail"
			activate
			set theSender to "ryan@domain.org" (*Set this email address to the account Mail is using.*)
			set theSubject to "New Pix added" (*Change the subject to what you like/need.*)
			set theHost to "mac" (*Set this to the computer this is running on - helpful if you have multiple machines.*)
			set theAddress to "user@gmail.com, user@hotmail.com" (*Set this email address to where you want the notification delivered.*)
			set thebody to "This e-mail is to inform you that (" & knt & ") new pictures have been added to family website. Come check them out! http://www.domain.com" (*This is the body of the email-adjust as you like.*)
			(* preceeding instruction EDITED *)
			set newMessage to make new outgoing message with properties {subject:theSubject, content:thebody, sender:theSender, address:theAddress}
			tell newMessage
				make new to recipient with properties {address:theAddress}
			end tell
			send newMessage
		end tell
		
	on error msg
		tell application (path to frontmost application as text) to display dialog "ERROR:" & return & return & msg
	end try
	tell application (path to frontmost application as text) to display dialog "email sent..."
	
end adding folder items to

Yvan KOENIG (from FRANCE lundi 2 octobre 2006 20:22:2)

Perfect! Thank you!

Ryan