Switch printer preset in AppleScript via the shell

Mar 14, '07 07:30:03AM

Contributed by: fredgh

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.]

Comments (1)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20070312100620242