Skip to content

Instantly share code, notes, and snippets.

@andrewthauer
Created April 28, 2015 11:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrewthauer/afd6b5c9414f71f23b4c to your computer and use it in GitHub Desktop.
Save andrewthauer/afd6b5c9414f71f23b4c to your computer and use it in GitHub Desktop.
(*
Author: Anil Natha
Description:
This script toggles the visibility of hidden files in OS X. This includes
showing hidden files in Finder windows and on the desktop.
Last Updated: 2015-02-20
*)
tell application "System Events"
try
set hiddenFilesDisplayStatus to do shell script "defaults read com.apple.finder AppleShowAllFiles"
on error
set hiddenFilesDisplayStatus to "NO"
end try
set hiddenFilesNewDisplayStatus to "NO"
if hiddenFilesDisplayStatus is "NO" then
set hiddenFilesNewDisplayStatus to "YES"
end if
do shell script "defaults write com.apple.finder AppleShowAllFiles " & hiddenFilesNewDisplayStatus
end tell
tell application "Finder"
set allWindows to windows
repeat with currentWindow in allWindows
set currentWindowView to get the current view of the currentWindow
set alternateWindowView to list view
if currentWindowView is list view then
set alternateWindowView to icon view
end if
set the current view of the currentWindow to alternateWindowView
set the current view of the currentWindow to currentWindowView
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment