lohenyumnam
11/11/2017 - 3:31 AM

Create a Toggle Hidden Files Menu Item.md

Create a Toggle Hidden Files Menu Item

  • Launch Automator
  • Select Service as the type of template to use for your new Automator task, and click the Choose button
  • In the Library pane, make sure Actions is selected, then underneath the Library item, click Utilities. This will filter the available workflow types to just those relating to utilities.
  • In the filtered list of actions, click Run Shell Script and drag it to the workflow pane.
  • At the top of the workflow pane are two drop-down menu items. Set the 'Service receives selected' to 'files or folders.' Set the 'in' to 'Finder.'
  • Copy the entire shell script command (all six lines), and use it to replace any text that may already be present in the Run Shell Script box.
STATUS='defaults read com.apple.finder AppleShowAllFiles'
if [ $STATUS == 1 ]
then defaults write com.apple.finder AppleShowAllFiles -boolean FALSE
else defaults write com.apple.finder AppleShowAllFiles -boolean TRUE
fi
killall Finder
  • From the Automator file menu, select "Save," and then give the service a name. The name you select will appear as the menu item. I call mine Toggle Hidden Files.
  • After saving the Automator service, you can quit Automator.

Using the Toggle Hidden Files Menu Item

  • Open a Finder window.
  • Right-click any file or folder.
  • Select Services, Toggle Hidden Files, from the pop-up menu.
  • The Finder will toggle the state of hiding files, causing hidden files and folders to display or be hidden depending on their current condition.