Updated script to create dual Finder windows

Aug 20, '10 07:30:00AM

Contributed by: llee

I revisited this hint recently. This script should be compatible with Tiger and higher system versions. It tries to make tandem windows from bottom of the screen up from the first two eligible Finder windows. If only one eligible window is available, it uses that one and creates another, and if no eligible windows are available, it creates and arranges two. It doesn't respect Spaces, so if a single eligible window exists, the existing window and the new window may end up in different spaces.

Here is the modified script. You can save it to ~/Library/Scripts/Applications/Finder to make it available from the AppleScript menu. You may need to create the Finder folder.

set danswer to (do shell script "/usr/sbin/system_profiler SPDisplaysDataType | grep Resolution")
set monitor_width to (word 2 of danswer) div 1
set monitor_height to (word 4 of danswer) div 1
set hit1 to false
set hit2 to false
tell application "Finder"
 activate
 set window_count to the count of windows
 repeat with i from 1 to window_count
  try
   if not hit1 then
    set the current view of window i to column view
    set the bounds of window i to {0, ((monitor_height * 0.33) div 1 - 23), monitor_width, (monitor_height * 0.66) div 1 - 23}
    set hit1 to true
    if not hit2 then
     set the current view of onenewwin to column view
     set the bounds of onenewwin to {0, (monitor_height * 0.66) div 1, monitor_width, monitor_height}
     set hit2 to true
     exit repeat
    end if
   else
    set the current view of window i to column view
    set the bounds of window i to {0, (monitor_height * 0.66) div 1, monitor_width, monitor_height}
    set hit2 to true
    exit repeat
   end if
  end try
 end repeat
 if hit1 and hit2 then
 else if hit1 then
  set newwin to make new Finder window
  set the current view of newwin to column view
  set the bounds of newwin to {0, (monitor_height * 0.66) div 1, monitor_width, monitor_height}
 else if not hit1 and not hit2 then
  set onehit to 2
  set onenewwin to make new Finder window
  set the current view of onenewwin to column view
  set the bounds of onenewwin to {0, ((monitor_height * 0.33) div 1 - 23), monitor_width, (monitor_height * 0.66) div 1 - 23}
  set twonewwin to make new Finder window
  set the current view of twonewwin to column view
  set the bounds of twonewwin to {0, (monitor_height * 0.66) div 1, monitor_width, monitor_height}
 end if
end tell


[crarko adds: I tested it in 10.6.4, and it works as described. The AppleScript source is mirrored here.]

Comments (10)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20100820051308518