Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Switch printer preset in AppleScript via the shell Printers
I needed to change my printer's advanced print setup automatically with AppleScript. AppleScript doesn't support this feature, so I found a way to do it with a shell script. First, create and save a custom settings preset in the printing dialog. For this example, assume those settings are named Preset1. Then, in the AppleScript Script Editor, enter the following code:
do shell script 
 "defaults write com.apple.print.custompresets 
 com.apple.print.lastPresetPref Preset1"
This way, the Preset1 settings will be used next time you print.

[robg adds: I broke the AppleScript onto three lines for better display here. I didn't want to use the AppleScript line break character, though, because the text inside the quotes cannot be broken in that manner. If you're going to use this code snippet, enter it as one long line with a space replacing each line break.]
    •    
  • Currently 2.13 / 5
  You rated: 2 / 5 (8 votes cast)
 
[11,083 views]  

Switch printer preset in AppleScript via the shell | 1 comments | Create New Account
Click here to return to the 'Switch printer preset in AppleScript via the shell' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Switch printer preset in AppleScript via the shell
Authored by: ctierney on Mar 15, '07 06:36:43AM
Hi Rob,

FWIW, I discovered recently that the do shell script string can contain line breaks, which can help shorten long lines:
do shell script "
  defaults write com.apple.print.custompresets com.apple.print.lastPresetPref Preset1
"
--
Cole

[ Reply to This | # ]