Re: error attempting AppleShowAllFiles
Re: error attempting AppleShowAllFiles
- Subject: Re: error attempting AppleShowAllFiles
- From: Ron Hunsinger <email@hidden>
- Date: Fri, 21 Oct 2011 11:21:56 -0700
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.
There is a more subtle bug in the script you supply. An application's preference file should not be modified (except by the application itself) while the application is running. The script should quit Finder *before* mucking around with its defaults.
Try this:
tell application "Finder" to quit
delay 0.2
try
set dotVisible to do shell script "defaults read com.apple.Finder AppleShowAllFiles"
on error
set dotVisible to "0"
end try
if dotVisible = "0" then
do shell script "defaults write com.apple.Finder AppleShowAllFiles 1"
else
do shell script "defaults write com.apple.Finder AppleShowAllFiles 0"
end if
tell application "Finder" to activate
-Ron Hunsinger
On Oct 20, 2011, at 4:19 PM, DaveC wrote:
> This script worked under Snow Leopard. Now when run under Lion it gives this error:
>
> error "2011-10-20 15:30:29.887 defaults[4263:f07]
> The domain/default pair of (com.apple.Finder, AppleShowAllFiles) does not exist" number 1
>
> I'm not sure how to interpret the error.
>
> I did not write the script so cannot answer questions re. "why did you...?".
>
> Suggestions?
>
> Thanks,
> Dave
> (AS status: beginner)
>
> - - -
>
> set dotVisible to do shell script "defaults read com.apple.Finder AppleShowAllFiles"
> if dotVisible = "0" then
> do shell script "defaults write com.apple.Finder AppleShowAllFiles 1"
> else
> do shell script "defaults write com.apple.Finder AppleShowAllFiles 0"
> end if
> tell application "Finder" to quit
> delay 1
> tell application "Finder" to activate
> _______________________________________________
> 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
_______________________________________________
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