Macos – How to show/hide hidden files on Finder on Mac OS X 10.9 Mavericks

findermacososx-mavericks

The following script doesn't work on Mavericks:

# check if hidden files are visible and store result in a variable
isVisible=”$(defaults read com.apple.finder AppleShowAllFiles)”

# toggle visibility based on variables value
if [ "$isVisible" = FALSE ]
then
defaults write com.apple.finder AppleShowAllFiles -boolean true
else
defaults write com.apple.finder AppleShowAllFiles -boolean false
fi

# force changes by restarting Finder
killall Finder

UPDATED:

But the following script works:

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

Best Answer

Apple Script version works fine:

on run {input, parameters}

    set cur_state to do shell script "defaults read com.apple.finder AppleShowAllFiles"
    if cur_state = "TRUE" then
        do shell script "defaults write com.apple.finder AppleShowAllFiles FALSE"
    else
        do shell script "defaults write com.apple.finder AppleShowAllFiles TRUE"
    end if

    do shell script "killall Finder"

    return input
end run
Related Question