Re: Help about plist
Re: Help about plist
- Subject: Re: Help about plist
- From: KOENIG Yvan <email@hidden>
- Date: Thu, 2 Oct 2008 14:39:23 +0200
Le 2 oct. 2008 à 13:21, Axel Luttgens a écrit :
Le 1 oct. 08 à 21:20, KOENIG Yvan a écrit :
Hello
I wrote this script to copy an array from the Pages plist to the
Numbers one.
It fails when I try to write the new plist on disk.
May you help me ?
-- [SCRIPT]
[...]
-- [/SCRIPT]
I'm running 10.4.11
Hello Yvan,
As Shane already noticed, the Property List Suite received R/W
capabilities with Leopard.
But perhaps could you make use of the defaults commands.
The basic idea would be:
do shell script "K=`defaults read com.apple.iWork.Pages
kSFWPAutoSubstitutionArrayProperty`; defaults write
com.apple.iWork.Numbers kSFWPAutoSubstitutionArrayProperty \"$K\""
But as always in such cases, please check and double check... ;-)
And be sure to have quit Numbers and to have taken a copy of its
plist before trying the above.
HTH,
Axel
In fact I assumed that building a new file was easier than editing an
existing file.
Given your responses, I choose the other track: I duplicate the
original file (for safe) then I change the original file contents.
--(SCRIPT copy SubstitutionArray]
(*
copy the autoCorrection array from "com.apple.iWork.Pages.plist" to
"com.apple.iWork.Numbers.plist" and "com.apple.iWork.Keynote.plist"
Save it as an Application Bundle.
Drag the icon of a Numbers document on the bundle's icon will do the
trick then open the doc in Numbers.
Yvan KOENIG (Vallauris, FRANCE)
2 octobre 2008
*)
property needBackup : true
(*
true = backup the original "com.apple.iWork.Numbers.plist" on the
Desktop
false = don't backup
*)
property launchNumbers : true
(*
true = activate Numbers before ending
false = don't activate Numbers
*)
property path2doc : ""
on run
set path2doc to ""
my main()
end run
on open sel
set path2doc to sel's item 1 as alias
my main()
end open
--===== Handlers
on main()
set p2p to path to preferences from user domain as text
set p2d to path to desktop from user domain as text
set plistPages to p2p & "com.apple.iWork.Pages.plist"
if needBackup then
(* creates a backup of "com.apple.iWork.Numbers.plist" and
"com.apple.iWork.Keynote.plist" on the Desktop *)
my backupPrefs("Numbers", p2p, p2d)
my backupPrefs("Keynote", p2p, p2d)
end if
my copyTo("Numbers", p2p, p2d, plistPages)
my copyTo("Keynote", p2p, p2d, plistPages)
if launchNumbers then
if path2doc is "" then
tell application "Numbers" to activate
else
tell application "Numbers" to open path2doc
end if
end if
set path2doc to ""
end main
--=====
on copyTo(ky, p2p_, p2d_, plistPages_)
local nameOfPlist, plist1, plist2, plistRec, xx
set nameOfPlist to "com.apple.iWork." & ky & ".plist"
set plist1 to p2p_ & nameOfPlist
set plist2 to p2d_ & nameOfPlist
tell application "System Events"
set plistRec to (value of property list file plist1)
try
set xx to |kSFWPAutoSubstitutionArrayProperty| of plistRec
on error (* there was no such array, we build one *)
set plistRec to (plistRec & {|kSFWPAutoSubstitutionArrayProperty|:
{}})
end try
set |kSFWPAutoSubstitutionArrayProperty| of plistRec to |
kSFWPAutoSubstitutionArrayProperty| of (get value of property list
file plistPages_)
set value of property list file plist1 to plistRec
end tell -- System Events
end copyTo
--=====
on backupPrefs(ky, p2p_, p2d_)
local nameOfPlist, plist1, plist2
set nameOfPlist to "com.apple.iWork." & ky & ".plist"
set plist1 to p2p_ & nameOfPlist
set plist2 to p2d_ & nameOfPlist
tell application "Finder"
if exists file plist2 then delete file plist2
duplicate (plist1 as alias) to folder p2d_
end tell -- Finder
end backupPrefs
--[/SCRIPT]
Yvan KOENIG (from FRANCE jeudi 2 octobre 2008 14:38:35)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden