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

Toggle Sidebar in all open Finder windows Desktop
Here's an AppleScript that toggles the presence of the sidebar in all Finder windows. Toggle status is determined by that of the front window. In Tiger, it sets the sidebar to its minimum width; in Snow Leopard, it hides it completely. The script leaves the toolbar alone.
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
            end tell
          end if
          tell application "Finder"
            if index of window my_id ≠ 1 then
              open window my_id
            else
              if Showsidebar then
                tell application "Finder"
                  tell front window to set sidebar width to 150
                end tell
              else
                tell application "Finder"
                  tell front window to set sidebar width to 0
                end tell
              end if
              
            end if
          end tell
        end tell
        if my_test then
          if Showsidebar then
            tell application "Finder"
              tell front window to set sidebar width to 150
            end tell
          else
            tell application "Finder"
              tell front window to set sidebar width to 0
            end tell
          end if
        end if
      end tell
      tell application "Finder"
        set index of window my_id to my_num
      end tell
    end repeat
  end if
end tell
[robg adds: I tested this in both 10.5 and 10.6, and it works as described.]
    •    
  • Currently 2.00 / 5
  You rated: 2 / 5 (8 votes cast)
 
[6,738 views]  

Toggle Sidebar in all open Finder windows | 5 comments | Create New Account
Click here to return to the 'Toggle Sidebar in all open Finder windows' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Toggle Sidebar in all open Finder windows
Authored by: rpaege on Sep 23, '09 12:08:17PM

It works in Leopard, but it also switches spaces to space 2, no matter which space I'm in. It's unclear to me from the script why it does this, and how to stop it.



[ Reply to This | # ]
Toggle Sidebar in all open Finder windows
Authored by: rpaege on Sep 23, '09 01:09:08PM

Never mind. I had a hidden window in that space :/

The script works as advertised in both Leopard and Snow Leopard.



[ Reply to This | # ]
Sidebar only reduced... not eliminated.
Authored by: Ronald Lanham on Sep 23, '09 02:17:31PM

Running 10.5.8

This script only reduces sidebar in Finder windows to what appears to be around 150 pixels... not zero pixels.

Any ideas how I can make it completely eliminate the sidebar?



[ Reply to This | # ]
Sidebar only reduced... not eliminated.
Authored by: baltwo on Sep 24, '09 01:02:30PM

The minimum sidebar width in Leopard is 135 pixels. Can't be any less.

In Snow Leopard, why bother, since CMD+OPTION+S Hides/Shows the sidebar.



[ Reply to This | # ]
Sidebar only reduced... not eliminated.
Authored by: robg on Oct 08, '09 06:07:15AM

Command-Option-S only hides the sidebar in the current window. The script hides it in *all* open windows.

-rob.



[ Reply to This | # ]