Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Editing .plist

Editing .plist
Thread Tools
Fresh-Faced Recruit
Join Date: Dec 2003
Status: Offline
Reply With Quote
Dec 5, 2003, 06:14 AM
 
Hi, I'd like to control the printing system in 10.3 without having to select options in the print dialog boxes. I already have all of my print settings stored as a custom profile named 'CoverPrint2'. This profile is stored in

Library/preferences/com.apple.print.custompresets.plist

and here is what the file contains (well, the important part anyway):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CoverPrint</key>
<dict>
<key>com.apple.print.preset.id</key>
<string>CoverPrint2</string>
<key>com.apple.print.preset.settings</key>
<dict>
<key>com.apple.print.PrintSettings.PMCopies</key>
<integer>88</integer>


Okay - still with me? What I really want to do is to be able to enter a command of the form

defaults write xxxx

to enable me to change the PMCopies property. Then, I can have control ver the default number of copies printed. Anyone know the command I should use? Thanks in advance
     
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Dec 5, 2003, 05:21 PM
 
my guess would be:

defaults write com.apple.print.custompresets com.apple.print.PrintSettings.PMCopies 42

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
Fresh-Faced Recruit
Join Date: Dec 2003
Status: Offline
Reply With Quote
Dec 9, 2003, 08:37 AM
 
Cheers for the response. However, when I try this, it just creates a new key at the bottom of the document. I think that becuase the value I want to change is so 'nested', I will need a longer 'address' to pass to defaults.

Any more ideas greatly appreciated
     
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status: Offline
Reply With Quote
Dec 10, 2003, 12:10 PM
 
&nbsp;&nbsp;&nbsp;As far as anyone I know has been able to determine, defaults can only edit at a limited depth. One can use defaults to read data into a script, edit it and write it back but at that point, it's easier to just edit the propertylist directly. You said that the propertylist was in Library/preferences but you didn't say which one. I'll assume it's in your home directory. The following script takes a number as an argument and replaces the PMCopies value with that number:

#!/bin/bash

cd ~/Library/preferences
mv com.apple.print.custompresets.plist com.apple.print.custompresets1.plist

awk '! /PrintSettings\.PMCopies/; /PrintSettings\.PMCopies/{ print; getline; sub( /<integer>[0-9]*<\/integer>/, "<integer>'$1'</integer>" ); print }' com.apple.print.custompresets1.plist > com.apple.print.custompresets.plist

rm com.apple.print.custompresets1.plist

If my assumption about where the propertylist is, just change the "cd" line. I hope this does what you want.
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:57 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2