Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'An AppleScript to quickly show or hide hidden files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to quickly show or hide hidden files
Authored by: brising on Apr 10, '03 04:16:37PM

I found that I needed to add a bit to the line which read the current state of AppleShowAllFiles, as mine was set to 0:

if inOff= "NO" or inOff= "OFF" or inOff= "0" then

(boldface added) made things work OK.

Great idea!

-- Bill

P.S. in the preview for this note, the onOff in the code is showing up as inOff for some inexplicable reason...



[ Reply to This | # ]
An AppleScript to quickly show or hide hidden files
Authored by: jglenn on Aug 25, '03 10:08:24PM

yes, the original script didn't work for me, either, because the preference had never been set, ever, and so the "read" command failed with a dialog error message.

So, here's my improved version which doesn't display the error on newbies' systems:

set onOff to "NO"

try
set onOff to do shell script "defaults read com.apple.finder AppleShowAllFiles"
end try

if onOff = "NO" or onOff = "OFF" or onOff = "0" then
set newState to "show"
set OnOffCommand to "defaults write com.apple.finder AppleShowAllFiles ON"
else
set newState to "hide"
set OnOffCommand to "defaults write com.apple.finder AppleShowAllFiles OFF"
end if

display dialog "Are you sure you want to " & newState & " hidden files? (This will restart the Finder)" buttons {"Cancel", "OK"} default button 2
copy the result as list to {buttonPressed}
if the buttonPressed is "OK" then
try
tell application "Finder" to quit
do shell script OnOffCommand
delay 1
tell application "Finder" to launch
end try
end if



[ Reply to This | # ]