Resize, Rename, & Archive script

Hello All,
I was wondering if you could help me with- what I would imagine would be- a relatively easy Applescript. I was hoping that I could have the Applescript…

A) Resize JPG(s) to a max longest length (either height or width) of 480 pixels.
B) Rename the JPG to the folder name- which… the JPG is actually in a folder within a folder. For instance, folder “X” contains folder “Y” which contains the JPG. I would like the JPG to be renamed “folder “X” name.jpg”.
C) Take the renamed JPG and move it to a static location on a server.

Here is what I have so far… which is ‘A’ from above…


on open some_items
	repeat with this_item in some_items
		try
			rescale_and_save(this_item)
		end try
	end repeat
end open


to rescale_and_save(this_item)
	tell application "Image Events"
		launch
		set the target_width to 480
		-- open the image file
		set this_image to open this_item
		
		set typ to this_image's file type
		
		copy dimensions of this_image to {current_width, current_height}
		if current_width is greater than current_height then
			scale this_image to size target_width
		else
			-- figure out new height
			-- y2 = (y1 * x2) / x1
			set the new_height to (current_height * target_width) / current_width
			scale this_image to size new_height
		end if
		
		tell application "Finder" to set new_item to ¬
			(container of this_item as string) & "scaled." & (name of this_item)
		save this_image in new_item as typ
		
	end tell
end rescale_and_save

Is it possible to have this script perform steps ‘B’ and ‘C’?

Thanks in advance!
bryan