Skip to content

Instantly share code, notes, and snippets.

@swilliams
Created May 20, 2011 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swilliams/982258 to your computer and use it in GitHub Desktop.
Save swilliams/982258 to your computer and use it in GitHub Desktop.
Watch a folder and print files that are added to it
-- Appropriated from: http://hints.macworld.com/article.php?story=20041104011839378
on adding folder items to this_folder after receiving these_items
try
tell application "Finder"
repeat with i from 1 to number of items in these_items
try
set this_item to item i of these_items
set the path_string to this_item as string
set the final_path to POSIX path of the path_string
do shell script "/usr/bin/lp '" & final_path & "'"
on error error_message
tell application "Finder"
display dialog "Error for item " & (this_item as string) ¬
& ": " & error_message buttons {"Continue", "Cancel"} ¬
default button 1 giving up after 120
end tell
end try
end repeat
end tell
on error error_message
tell application "Finder"
display dialog error_message buttons {"Cancel"} ¬
default button 1 giving up after 120
end tell
end try
end adding folder items to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment