Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,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 4.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[6,016 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 whomever posted them. This site is not responsible for what they say.
Switch printer preset in AppleScript via the shell
Authored by: ctierney on Thu, Mar 15 2007 at 6:36AM PDT
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 | # ]