Om je alvast op weg te helpen:
Zet dit in Script Editor en save als Application (het wordt een dropscript):
[code:1:d876be7abd]global item_counter
on run
set the item_counter to 0
tell application "Finder"
activate
set this_folder to (the target of the front window) as alias
my processor()
my process_folder(this_folder)
my display_result(item_counter)
end tell
end run
– This droplet processes both files or folders of files dropped onto the applet
on open these_items
set the item_counter to 0
–get_angle()
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
if folder of the item_info is true then
process_folder(this_item)
else if (alias of the item_info is false) then
process_item(this_item)
end if
end repeat
my display_result(item_counter)
end open
– this sub-routine processes folders
on process_folder(this_folder)
set these_items to list folder this_folder without invisibles
repeat with i from 1 to the count of these_items
set this_item to alias ((this_folder as text) & (item i of these_items))
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else if (alias of the item_info is false) then
process_item(this_item)
end if
end repeat
end process_folder
– this sub-routine processes single files
on process_item(this_item)
try
set unixpath to unix_path(this_item)
– put your shell script here
set command to "lpr -o raw " & unixpath
do shell script command
set the item_counter to the item_counter + 1
on error error_message
tell application "Finder"
activate
display dialog error_message buttons {"Cancel"} default button 1
end tell
end try
end process_item
– this sub-routine changes the mac file path (bla:blabla:blablabla) to a unix-like file path
on unix_path(mac_path)
set unixpath to (POSIX path of mac_path)
set chars to every character of unixpath
repeat with i from 1 to length of chars
if “!$&”’*(){[|;<>?~` " contains (item i of chars as text) then
set item i of chars to "" & (item i of chars as text)
end if
end repeat
return every item of chars as string
end unix_path
– display final result
on display_result(item_counter)
if the item_counter is 0 then
set the display_message to "Er zijn geen documenten geprint"
else if the item_counter is 1 then
set the display_message to "Eén document wordt geprint"
else
set the display_message to ((item_counter as string) & " documenten worden geprint.")
end if
tell application "Finder"
activate
display dialog display_message buttons {"?"} default button 1 giving up after 2
end tell
end display_result[/code:1:d876be7abd]
Het script is een beetje van mezelf en een beetje van maggi (en apple en james sorenson). Je zult ongetwijfeld nog wel een aantal dingen moeten aanpassen maar het zou al moeten werken.
Meer applescript info op developer.apple.com