3

How to show/hide invisible files and folders from Service menu?

By default files and folders whose name start with . is invisible. In order to show them, you can use the following command in Terminal.

defaults write com.apple.finder AppleShowAllFiles -boolean true; killall Finder

To restore the default state, in which those files are hidden, use the following.

defaults delete com.apple.finder AppleShowAllFiles; killall Finder

How can I toggle the status of AppleShowAllFiles key without launching Terminal?

1

Apologies if this is a little off-topic from your question, but, in macOS Sierra you can toggle showing hidden files right in the Finder with Shift+cmd+.

0
  1. Launch Automator
  2. Choose Service for new document.
  3. From "Actions" menu, choose Utilities > Run Shell Script. Double click it in the menu, or drag and drop it into the right pane.
  4. Make sure "Service receives" is set to no input in Finder
  5. Add the following shell script into the Run Shell Script

    S1=`defaults read com.apple.finder AppleShowAllFiles`
    C1='defaults write com.apple.finder AppleShowAllFiles -boolean'
    
    # spaces within brackets are important
    if [[ $S1 == '1' ]]; then
    $C1 false
    elif [[ $S1 == '0' ]]; then
    $C1 true
    else 
    # does not exist
    $C1 true
    fi
    killall Finder
    
  6. Save it with an appropriate name such as "ToggleInvisible"

  7. Make sure in System Preference > Keyboard > Shortcuts > Services > General, the service you created is shown and ticked.
  8. Now go to Finder and click Finder menu > Services > "ToggleInvisible" (or your choice of name) to see the effect.

Or if you prefer, choose Application instead of Service at the beginning in Automator.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .