Re: error attempting AppleShowAllFiles
Re: error attempting AppleShowAllFiles
- Subject: Re: error attempting AppleShowAllFiles
- From: Luther Fuller <email@hidden>
- Date: Fri, 21 Oct 2011 14:52:31 -0500
On Oct 21, 2011, at 1:21 PM, Ron Hunsinger wrote: The problem is that Finder will honor a setting for AppleShowAllFiles, but does not set one by default. Until a value is explicitly set, you'll get the error message saying so. In the meantime, Finder will proceed AS IF it had been set to 0. The reason you're getting the error now isn't because you moved to Lion, but because you moved to a new machine (or at least created a new user), and AppleShowAllFiles hasn't yet been given a value for this user on this machine.
So the remedy is to do what Finder does: assume it's 0 if it hasn't been set.
The default values for many preference settings is often indicated by a missing key in a .plist file. This is true for the Finder and for applications.
For example, I needed to determine if a mailbox in Mail was displaying messages with "Organize by Thread" true or false. This value is contained in the "Info.plist" file within the .mbox folder containing the messages for that mailbox. I was getting an error reading that value until I realized that the default value of 'true' is indicated by a missing DisplayInThreadedMode key. My script became ...
tell application "System Events" (mailboxAlias as text) & "Info.plist" try value of property list item "DisplayInThreadedMode" of property list file the result -- ("yes" or "no"), this key may not exist on error return true end try set nowThreaded to (the result = "yes") end tell
This is the way you have to handle all preference values whether you use System Events or 'do shell script "defaults read ..." '.
|
_______________________________________________
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