Project:Sandbox

(* Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software.

In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software ( the "Apple Software" ), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and / or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.

The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON - INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.

IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND / OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT ( INCLUDING NEGLIGENCE ), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Copyright ( C ) 2011 Apple Inc. All Rights Reserved.

(* INSTRUCTIONS This template is an example of how a droplet can also have user-accessible properties. This droplet is designed to process one or more files, whose icons are dragged onto the droplet icon. The droplet also provides access to user-settable properties through a dialog displayed when the applet is run as an application. To use, place your file processing code in the process_item sub-routine. Save as an application.

property type_list : {} -- e.g.: {"PICT", "JPEG", "TIFF", "GIFf"} property extension_list : {} -- e.g.: {"txt", "text", "jpg", "jpeg"}, NOT: {".txt", ".text", ".jpg", ".jpeg"} property typeIDs_list : {} -- e.g.: {"public.jpeg", "public.tiff", "public.png"}

property post_alert : "Yes"

on run repeat display dialog "This droplet will process files dragged onto its icon." & linefeed & linefeed & "There is a user-settable preference for displaying an alert dialog when the droplet encounters a dragged-on item that is not a file of the type processed by the droplet." & return & return & "Post User Alert: " & (post_alert as text) buttons {"Set Prefs", "Done"} default button 2 with title "My File Processing Droplet" if the button returned of the result is "Set Prefs" then display dialog "Should this droplet post an alert dialog when items that are not files are dragged onto it?" & return & return & "Current Status: " & (post_alert as text) buttons {"No", "Yes"} default button post_alert if the button returned of the result is "Yes" then set post_alert to "Yes" else set post_alert to "No" end if		else return "done" end if	end repeat end run

-- This droplet processes files dropped onto the applet on open these_items repeat with i from 1 to the count of these_items set this_item to item i of these_items set the item_info to info for this_item set this_name to the name of the item_info try set this_extension to the name extension of item_info on error set this_extension to "" end try try set this_filetype to the file type of item_info on error set this_filetype to "" end try try set this_typeID to the type identifier of item_info on error set this_typeID to "" end try if (folder of the item_info is false) and (alias of the item_info is false) and ((this_filetype is in the type_list) or (this_extension is in the extension_list) or (this_typeID is in typeIDs_list)) then -- THE ITEM IS AN IMAGE FILE AND CAN BE PROCESSED process_item(this_item) else if post_alert is "Yes" then display alert "PROCESSING ALERT" message "The item “" & this_name & "” is not a file that this droplet can process." buttons {"Cancel", "Continue"} default button 2 cancel button "Cancel" as warning end if	end repeat end open

-- this sub-routine processes files on process_item(this_item) -- NOTE that the variable this_item is a file reference in alias format -- PLACE YOUR FILE PROCESSING STATEMENTS HERE end process_item