• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Toggle invisible files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Toggle invisible files


  • Subject: Re: Toggle invisible files
  • From: Nigel Garvey <email@hidden>
  • Date: Thu, 10 Nov 2016 11:07:10 +0000

2551phil wrote on Wed, 09 Nov 2016 23:46:28 +0700:

>
>> On 9 Nov 2016, at 14:17, DaveC <email@hidden> wrote:
>>
>> What exactly is changed in the dictionary for Mav that breaks this?
>
>Nothing.
>
>Your script is failing on the ‘read’ command because the defaults pair
>doesn’t exist on a new install until you write it.
>
>You can just rap a ‘try' around the ‘read’ command and change the ‘if’
>condition to “if dotVisible is not 1” and your script will work as
before.

Another approach would be to read the whole defaults text and see if it
contains "AppleShowAllFiles = 1;". If not, it either contains the 0
setting or neither; it doesn't matter which:

  set FinderDefaults to (do shell script "defaults read com.apple.finder")
  if (FinderDefaults contains "AppleShowAllFiles = 1;") then
    do shell script "defaults write com.apple.finder AppleShowAllFiles 0; killall Finder"
  else
    do shell script "defaults write com.apple.finder AppleShowAllFiles 1; killall Finder"
  end if


>> On 10 Nov 2016, at 07:20, Shane Stanley <email@hidden>
wrote:
>>
>> there are several values other than "1"
>
>‘Yes’, ‘true’ and ‘1’ - you’re right I was a bit hasty there.

Here's a one-shell-script offering:

  do shell script "newState=$(
    defaults read com.apple.finder |
    sed -En '/ *AppleShowAllFiles *= *(1|[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]).*/ {
      # If the ‘on’ setting is found, store “0” in the hold space.
      s//0/
      h
    }
    $ {
      # Output the hold space contents at the end, or “1” if none.
      g
      /^$/ s//1/
      p
    }'
  ) ;
  defaults write com.apple.finder AppleShowAllFiles $newState ;
  killall Finder"


NG

 _______________________________________________
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


  • Follow-Ups:
    • Re: Toggle invisible files
      • From: 2551phil <email@hidden>
  • Prev by Date: Re: Toggle invisible files
  • Next by Date: Re: Toggle invisible files
  • Previous by thread: Re: Toggle invisible files
  • Next by thread: Re: Toggle invisible files
  • Index(es):
    • Date
    • Thread