Folder Actions & Entourage

Hello!
I’m learning applescritpt & need help. My co=worker have a set a Photoshop actions that saves images in different file formats in the server. When she is processing images with Photoshop actions I want to know when a new jpg is proccessed. So I’m using a folder action add - new item alert.scpt for the folder containing the jpgs that will alert me new images has been placed & if I want to view the added images " yes" or “no”. This so far is OK but I would like to have more control but I don’t know how.

What I want if I click on button “yes” I want the finder to reveal the new items added & then I want Entourage 2004 version11.3.3 to save as a draft email listing the file names of new images added in the jpg folder. The reason why I want Entorage to save a draft email I can edit the email before is sent to another people in the dept & I don’t want to bombard with emails my co-workers for every jpg placed in that folder like example if 10 jpgs are received & then Entourage will send 10 emails for each jpg placed in that folder. If it best for every 5 jpgs send an email? Well that’s why I would love to hear from you; the experts

Please see the script & help with suggestions in how to approach this.
on adding folder items to this_folder after receiving added_items
try
tell application “Finder”
–get the name of the folder
set the folder_name to the name of this_folder
end tell

	-- find out how many new items have been placed in the folder
	set the item_count to the number of items in the added_items
	--create the alert string
	set alert_message to ("Folder Actions Alert:" & return & return) as Unicode text
	if the item_count is greater than 1 then
		set alert_message to alert_message & (the item_count as text) & " new items have "
	else
		set alert_message to alert_message & "One new item has "
	end if
	set alert_message to alert_message & "been placed in folder " & «data utxt201C» & the folder_name & «data utxt201D» & "."
	set the alert_message to (the alert_message & return & return & "Would you like to view the added items?")
	
	display dialog the alert_message buttons {"Yes", "No"} default button 2 with icon 1 giving up after dialog_timeout
	set the user_choice to the button returned of the result
	
	if user_choice is "Yes" then
		tell application "Finder"
			--go to the desktop 
			activate
			--open the folder
			open this_folder
			--select the items
			reveal the added_items
			set sort column of list view options of Finder window 1 to modification date column
		end tell
	end if
	
	if user_choice is "Yes" then
		tell application "Microsoft Entourage"
			activate
			set themessage to make new outgoing message with properties {recipient:"nellbern@bellsouth.net", subject:"New images added to

IT-Web folder", content:“Go to the following folders: IT-web> jpg”}
repeat with i from 1 to item_count
make new attachment at themessage with properties {file:(item i of added_items)}
end repeat
set messID to the result
send messID
end tell
end if
end try
end adding folder items to

Not to sound nitpickish or anything, but it really does make your script easier to read and troubleshoot if, right before you post, you select it (the script, the whole script, and nothing but the script- this is important) and click the applescript button right over the smilies. This adds nice, shiny applescript tags that I would show you right now if putting them in didn’t mean that the whatever it is that does that makes into a box and link- you’ll see.
This is your script with applescript tags:

on adding folder items to this_folder after receiving added_items
    try
        tell application "Finder"
            --get the name of the folder
            set the folder_name to the name of this_folder
        end tell
        
        -- find out how many new items have been placed in the folder
        set the item_count to the number of items in the added_items
        --create the alert string
        set alert_message to ("Folder Actions Alert:" & return & return) as Unicode text
        if the item_count is greater than 1 then
            set alert_message to alert_message & (the item_count as text) & " new items have "
        else
            set alert_message to alert_message & "One new item has "
        end if
        set alert_message to alert_message & "been placed in folder " & «data utxt201C» & the folder_name & «data utxt201D» & "."
        set the alert_message to (the alert_message & return & return & "Would you like to view the added items?")
        
        display dialog the alert_message buttons {"Yes", "No"} default button 2 with icon 1 giving up after dialog_timeout
        set the user_choice to the button returned of the result
        
        if user_choice is "Yes" then
            tell application "Finder"
                --go to the desktop 
                activate
                --open the folder
                open this_folder
                --select the items
                reveal the added_items
                set sort column of list view options of Finder window 1 to modification date column
            end tell
        end if
        
        if user_choice is "Yes" then
            tell application "Microsoft Entourage"
                activate
                set themessage to make new outgoing message with properties {recipient:"nellbern@bellsouth.net", subject:"New images added to
IT-Web folder", content:"Go to the following folders: IT-web> jpg"}
                repeat with i from 1 to item_count
                    make new attachment at themessage with properties {file:(item i of added_items)}
                end repeat
                set messID to the result
                send messID
            end tell
        end if
    end try
end adding folder items to

Isn’t that better? Now, for your problem…

Firstly, although you don’t seem to be having any problems, I would avoid reusing variables (such as alert_message). I also like the style alertMessage better, although that’s just me thinking it is easier to read without underscores, and you don’t need to change that.

and secondly, it looks as if you didn’t have any problems in the first place, but were asking advice. I think that an email a jpg is going to get pretty annoying, and here is my suggestion:
When you get a jpg, set it to a variable such a jpg1, and then the next one set to jpeg2, etc. until you have enough to send about 5-10 in my opinion. on the fifth/tenth jpg, send your message with jpg1, jpg2, etc. and then set them all to “”. Additionally if you can figure out how you might be able to add an action (forgive me if I talk like we’re using Automator) to send it if it hasn’t sent at the end of the day.

also, I don’t know what «data utxt201C» and «data utxt201D» is, as whenever things like that start showing up in my code (and I know I didn’t write them, because I don’t know how to make the double-< or ->) I usually take it as a sign that I need to write that part over.

I like your commenting, at least at first. It’s a good habit, and you should continue for the rest of the script, as it will make any long scripts you make (presently I have one that’s 430 lines, and I recently got rid of a third of them, which would have made it about 645 lines, if my (Spotlight’s) calculations are correct. Now I learned about handlers, and hope it will shortly become 150 lines. (Seriously. That’s how many repeating code snippets I have) and comments really help me out a lot- although I am looking around for something somebody showed me sometime where you can collapse a section of your writing with one of those rotating triangles. Did I mention that the script is only a quarter done!?!) (sorry about my generous use of parentheses.)

Hope I helped!

Edit: Found the text editor- it’s BBEdit, and it’s FIFTY FREAKIN’ BUCKS!!! and that’s with the educational discount! (I like those). The regular version’s…um…no, I’m now typing into that window, so I can’t go check… well, I think it’s around a hundred!
The free demo’s pretty cool, though.

Edit of the Edit: It doesn’t do applescript! Not that I know of. I’m trying to find where I heard of it to find out more.