try set myvar to do shell script "defaults read com.apple.finder AppleShowAllFiles" if myvar is "FALSE" then do shell script "defaults write com.apple.finder AppleShowAllFiles TRUE" do shell script "killall Finder" else if myvar is equal to "TRUE" then do shell script "defaults write com.apple.finder AppleShowAllFiles FALSE" do shell script "killall Finder" else display dialog "Error" end if on error display dialog "Would you like to hide files or show files?" buttons {"Show", "Hide"} default button "Hide" set myChoice to button returned of result if myChoice is "Show" then do shell script "defaults write com.apple.finder AppleShowAllFiles TRUE" do shell script "killall Finder" else if myChoice is "Hide" then do shell script "defaults write com.apple.finder AppleShowAllFiles FALSE" do shell script "killall Finder" else display dialog "Error" end if end try