Hello
I’m looking for a script that will alert employees via their finder when items are uploaded to their folder on our server. I want to put it as a folder action. Has anyone seen something like this or could steer me in creating it?
I use this for items added to and removed from my ftp server.
on adding folder items to this_folder after receiving added_items
set the item_count to the count of items in the added_items
if the item_count is greater than 0 then
display dialog "ITEMS HAVE BEEN ADDED TO FTP" & return & item_count
end if
end adding folder items to
on removing folder items from this_folder
display dialog "ITEMS HAVE BEEN REMOVED FROM FTP"
end removing folder items from
You can also set up a file to record what’s in the file and keep a running count. (I haven’t tested this script – it’s just for illustration)
-- initialize a count file
try
set count_file to alias ((path to preferences folder from user domain as text) & "FTP_content_count.txt")
on error -- file not found
set FTP to open for access ((path to preferences folder from user domain as text) & "FTP_content_count.txt") with write permission
set eof of FTP to 0
write 0 to FTP
close access FTP
end try
on adding folder items to this_folder after receiving added_items
set the item_count to the count of items in the added_items
set prev_count to read count_file
if the item_count is greater than prev_count then
set FTP to open for access count_file with write permission
set eof of FTP to 0 -- erase earlier count
write prev_count + item_count to FTP
close access FTP
display dialog "ITEMS HAVE BEEN ADDED TO FTP" & return & "Current Count " & item_count - prev_count
end if
end adding folder items to
on removing folder items from this_folder after losing lost_items
set the item_count to the count of items in the lost_items
set prev_count to read count_file
if the item_count is less than prev_count then
set FTP to open for access count_file with write permission
set eof of FTP to 0
write prev_count - item_count to FTP
close access FTP
display dialog "ITEMS HAVE BEEN REMOVED FROM FTP" & return & "Current Count " & prev_count - item_count
end if
end removing folder items from