Hi all,
with help from my last posting, I have come up with another script I am trying to get to work correctly. I want the script when run look at a folder, and if the contents have changed within the last time the script was run, an email is generated. So if there are files that were there before, only newly added files are put into a list and sent.
Here is my script:
property retention : 1 * hours
on run
open {choose folder}
end run
on open source_folder
set start_time to (current date)
set source_folder to item 1 of source_folder as string
set cut_off to start_time - retention
set the_files to list folder (source_folder as alias) without invisibles
set files_to_email to {}
repeat with this_file in the_files
set this_file to text of this_file
try
set the_info to (get info for of ((source_folder & this_file) as alias))
if (creation date of the_info) < cut_off then set end of files_to_email to ((source_folder & this_file) as alias)
end try
end repeat
set curDate to (current date) as text
tell application "Mail"
activate
set this_message to make new outgoing message at beginning of outgoing messages
tell this_message
set visible to true
make new to recipient at beginning of to recipients ¬
with properties {address:"jsmith@yahoo.com", «class rdsn»:"John Smith"}
set subject to "New Files Received - " & curDate
set msgContent to "The following files were received: " & return
repeat with this_file in the_files
set msgContent to msgContent & return & this_file
set content to msgContent
end repeat
--send
end tell
end tell
return (current date) - start_time
end open
My problem is it always sends all files listed in the folder, not just newly added files/folders.
thanks for your help!
Chad