Ads by TechWords

See your link here
Receive the latest technology news and information.
Computerworld Daily News (First Look and Wrap-Up)
Computerworld Blogs Newsletter
The Weekly Top 10
Cloud Computing
View all newsletters




Privacy Policy
 

Toggle sidebar visibility in all open Finder windows

November 20, 2009 02:24 PM ET

Macworld - When I publish hints here on Macworld, I usually try to walk through and explain how they work, so as to help you understand what's going on behind the scenes. Sometimes, though, I'll just present a solution without much of an explanation, such as with today's hint.

Today's hint is an AppleScript that will toggle the visibility of the sidebar in all open Finder windows. In 10.6, you can do this for any one window with the View -> Hide (or Show) Sidebar menu item, but it only applies to the current window. Using the script in today's hint, you can toggle the visibility in all open windows.

While the script works in both 10.5 and 10.6, it's most useful in 10.6, because the script can't completely hide the sidebar in 10.5 (instead, it just shrinks down to its minimum width).

Another advantage to using this script in 10.6 is that it can be created as a Service, and then run via either the Services menu, or if you prefer, a keyboard shortcut.

The following instructions assume you're running 10.6; if you're running 10.5, you can either enter the code in the Script Editor, and save it as an application, or possibly create it in Automator and save it as a Finder Plug-In (though I haven't tested that).

In 10.6, launch Automator, and when the template chooser window appears, click Service then click Choose to open a new workflow. Near the top of the window that opens, on the right, you'll see two pop-up menus. Set the rightmost of those to Finder, then set the leftmost to "no input." (If you set the leftmost one first, then the Finder will disappear from the rightmost pop-up.)

Next, in the search box on the left, type run apples, which should be enough text to find just one matching action, Run AppleScript. Drag that action into the work area on the right, and then delete all of the placeholder code that's in the text area (on run {input...etc).

Insert the following code in its place:

set Showsidebar to true

tell application "Finder"

activate

if exists window 1 then

set allwins to every window whose collapsed is false

set my_num to 0

repeat with onewin in allwins

set my_num to my_num + 1

tell application "System Events"

tell process "Finder"

set my_id to the name of onewin

tell application "Finder"

try

set my_test to get ¬

toolbar visible of window my_id

on error

set my_test to false

end try

end tell

if my_test then

tell application "Finder"

if window my_id is window 1 then

set the_place to get sidebar width of window my_id

if the_place = 0 then

set Showsidebar to true

else

set Showsidebar to false

end if

end if


Originally published on www.macworld.com. Click here to read the original story.

Jump to comments

Apple

Additional Resources

Microsoft
Here are some of the key reasons why you would want to run Unified Access Gateway with DirectAccess.
Microsoft
Review how one energy firm tightened protection and simplified IT work using business-ready security solutions.
Sybase
In this white paper, IDC analyzes the role of next-generation mobile enterprise platforms as organizations seek a more strategic deployment of mobile solutions.

Learn the important issues you must consider before starting your next mobility initiative. Get your mobility white paper from IDC now, compliments of Sybase.

What People Are Saying

White Papers & Webcasts

High Performance for Integrating Massive Data Volumes
Processing very large data sets provides unique constraints, especially when time windows available for this processing are shrinking. This Technical White Paper presents...  

Gartner Podcast: Driving SharePoint Adoption in Lotus Notes Shops
Learn how can you drive mainstream user adoption of Microsoft SharePoint when your users are committed to using email.

IDC Webcast: Linux Adoption in a Global Recession
Access this webcast, compliments of Novell and HP, for a limited time only!

Whitepaper: Drive SharePoint Adoption in Lotus Notes Shops
Learn how you can drive your users to Microsoft SharePoint when they rely on IBM Lotus Notes.  


IT Jobs