Folder action to alert on max file size

hi total newbie,

I am trying to amend the apple folder action “add - new item alert.scpt” to display an alert message when a file is added to the folder which is over 5MB.

In the office we have a folder where pdfs are stored however some are dropped in too large for emailing.

Any help would be appreciated.


Perhaps something like this…

on adding folder items to this_folder after receiving these_items
	repeat with i from 1 to the count of items in these_items
		set this_item to item i of these_items
		tell application "Finder"
			set file_limit to 5242880 -- 5 MB in bytes
			if size of (info for this_item) is greater than file_limit then
				set item_name to name of this_item
				move this_item to path to desktop folder
				delay 0.2
				display dialog "The item: " & """ & item_name & """ & " exceeds the 5 MB limit and has been moved to the desktop!" with icon stop buttons ("OK") default button "OK"
			end if
		end tell
	end repeat
end adding folder items to

Hope this helps.


thanks ever so much that works a treat.