1 2 -- found this script here: http://forums.macosxhints.com/showpost.php?p=251001&postcount=3 3 -- i added the "delay 5" because after running script, finder didn't relaunch, maybe that's not needed on a faster machine 4 -- it's for toggling invisible files on and off in the finder, use for when i need to copy .htaccess files via a GUI 5 6 on run 7 set hiddenState to (do shell script "/usr/bin/defaults read com.apple.Finder AppleShowAllFiles") 8 try 9 if hiddenState = "0" or hiddenState contains "does not exist" then 10 set showPrompt to display alert "Are you sure you want to show all hidden files?" message "The Finder will quit and relaunch afterwards." buttons {"Cancel", "Show Hidden Files"} default button "Show Hidden Files" 11 if button returned of showPrompt = "Show Hidden Files" then 12 tell application "Finder" to quit 13 do shell script "/usr/bin/defaults write com.apple.Finder AppleShowAllFiles 1" 14 delay 5 --give finder time to quit so it can be relaunched below 15 else if button returned of showPrompt = "Cancel" then 16 return 0 17 end if 18 else if hiddenState = "1" then 19 set showPrompt to display alert "Are you sure you want to hide all hidden files?" message "The Finder will quit and relaunch afterwards." buttons {"Cancel", "Hide Hidden Files"} default button "Hide Hidden Files" 20 if button returned of showPrompt = "Hide Hidden Files" then 21 tell application "Finder" to quit 22 do shell script "/usr/bin/defaults write com.apple.Finder AppleShowAllFiles 0" 23 delay 5 --give finder time to quit so it can be relaunched below 24 else if button returned of showPrompt = "Cancel" then 25 return 0 26 end if 27 end if 28 on error theError 29 FinderCheck() 30 display alert theError as critical message "Changes may or may not have been made." 31 end try 32 FinderCheck() 33 end run 34 35 on FinderCheck() 36 tell application "System Events" 37 if (name of every process) does not contain "Finder" then 38 tell application "Finder" to launch 39 end if 40 end tell 41 end FinderCheck
You need to create an account or log in to post comments to this site.