I required a means to automatically print invoices saved by SageOne to my Google Drive.
- Open AppleScript Editor
- Copy the following code to the code window and compile
- Save the script to \Library\Scripts\Folder Action Scripts\
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
Now that you have created your script it is easy to apply it as a Folder Action to the folder of your choosing.
- Ctrl-Click (or right-click) the folder you wish to apply the Folder Action to, and Select Folder Actions Setup
- In the new windows select the script you created above and click Attach
- Add a file to the folder to test.
If all is well your file will print from either your current Default Printer, or the Last Used Printer.
Simple!
NOTE: This has been tested ONLY on OS X Mountain Lion.
If you have tested this script on other version of OS X please let us know it's compatibility!
NOTE: This has been tested ONLY on OS X Mountain Lion.
If you have tested this script on other version of OS X please let us know it's compatibility!