Skip to content

Instantly share code, notes, and snippets.

@keith
Created November 6, 2012 15:16
Show Gist options
  • Save keith/4025348 to your computer and use it in GitHub Desktop.
Save keith/4025348 to your computer and use it in GitHub Desktop.
Align your Finder windows side-by-side
-- By: @SmileyKeith
-- Vertically distributes your open finder windows for easy file movements
-- Thanks to @elasticthreads
tell application "Finder"
-- Get the number of Finder windows
set window_count to (count every Finder window)
-- Make sure there is an open Finder window
if window_count > 0 then
-- Get the height and width of the screen (only tested with 1 monitor)
-- Thanks to http://daringfireball.net/2006/12/display_size_applescript_the_lazy_way
set screen_bounds to bounds of window of desktop
set screen_width to item 3 of screen_bounds
set screen_height to item 4 of screen_bounds
-- Get the width that will be used for each window
set distributed_width to screen_width / window_count
-- Set the starting window x location
set window_x_location to 0
-- Loop through each window
repeat with window_num from 1 to window_count
-- Get the bounds of the current window
set window_bounds to bounds of Finder window window_num of application "Finder"
-- Get the x, y, width, and height from the window
set window_x to item 1 of window_bounds
set window_y to item 2 of window_bounds
set window_width to item 3 of window_bounds
set window_height to item 4 of window_bounds
-- Set the new bounds of the window
-- Could use `window_height` instead of `screen_height` if you wanted to maintain the original window height
set the bounds of Finder window window_num to {window_x_location, 0, distributed_width + window_x_location, screen_height}
-- Set the Finder window to column view
-- set current view of Finder window window_num to column view
-- Hide the sidebar to give you more room to work
-- set sidebar width of Finder window window_num to 0
-- Increment the window x location by the windows width
set window_x_location to window_x_location + distributed_width
end repeat
-- Make's the application active, just in case
activate
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment