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: hofman on Jul 25, '04 07:25:00AM
And then here is my version. The main difference is in the RelaunchFinder function which, oh surprise, relaunches the Finder. It tries several times to launch and therefore adjusts the delay to whatever is needed, which typically is less than 1 second.

tell application "Finder"
	activate
	set OnOff to "Off"
	set OnOff to do shell script "defaults read com.apple.finder AppleShowAllFiles"
	if OnOff is "OFF" or OnOff is "NO" or OnOff is "0" then
		set OnOff to "ON"
		set ShowHide to "show"
	else
		set OnOff to "OFF"
		set ShowHide to "hide"
	end if
	display dialog "Are you sure you want to " & ShowHide & " hidden files?" buttons {"Cancel", "OK"} default button 2
	set buttonPressed to the result
	if buttonPressed is "OK" then
		do shell script "defaults write com.apple.finder AppleShowAllFiles " & OnOff
		my RelaunchFinder()
	end if
end tell

on RelaunchFinder()
	try
		tell application "Finder" to quit
	on error
		error "Unable to quit Finder. You may want to force quitting it (cmd-option-esc) to have the change take effect."
	end try
	set finderIsActive to false
	set errorCount to 0
	repeat until finderIsActive
		try
			tell application "Finder" to activate
			set finderIsActive to true
		on error
			set errorCount to errorCount + 1
			if (errorCount > 20) then
				error "Unable to restart Finder. Please click the Finder icon in the dock to restart it."
			end if
			delay 0.2
		end try
	end repeat
end RelaunchFinder


[ Reply to This | # ]
An AppleScript to quickly show or hide hidden files
Authored by: granlord on Nov 19, '04 04:47:42PM

Tried this script and got the folowing error msg any ideas?

The domain/default pair of (com.apple.finder, AppleShowAllFiles) does not exist

Regards H



[ Reply to This | # ]