One small annoyance I have with the OS X Finder is its apparent inability to let me set a default Finder window size. However many times I resize windows with the mouse, the Finder will eventually reset them to some arbitrary dimensions.

If, like me, you find this aspect of the Finder's behaviour particularly irksome then try this AppleScript.

set localIP to do shell script "ifconfig en1|grep 'inet '|cut -d ' ' -f 2"
if localIP contains "xxx.xxx.x.xx" then
	-- iMac
	set defaultWidth to 808
	set defaultHeight to 471
	set defaultSidebarWidth to 192
else if localIP contains "xxx.xxx.x.xx" then
	-- MacBook 
	set defaultWidth to 758
	set defaultHeight to 421
	set defaultSidebarWidth to 142
end if

tell application "Finder"
	
	display dialog "Resize Finder Window(s)…." buttons {"Front", "All"} default button 1 giving up after 100
	
	if button returned of result contains "Front" then
		-- Front Finder Window only
		try
			set frontWindow to front Finder window
			set current view of frontWindow to column view
			set {windowLeft, windowTop, windowRight, windowBottom} to get bounds of frontWindow
			set bounds of frontWindow to {windowLeft, windowTop, windowLeft + defaultWidth, windowTop + defaultHeight}
			set sidebar width of frontWindow to defaultSidebarWidth
			set tBar to toolbar visible of frontWindow
			set toolbar visible of frontWindow to not tBar
			set toolbar visible of frontWindow to tBar
		end try
		
	else
		-- All Finder Windows
		repeat with x from 1 to count of Finder windows
			try
				set frontWindow to window x
				set {windowLeft, windowTop, windowRight, windowBottom} to get bounds of frontWindow
				set bounds of frontWindow to {windowLeft, windowTop, windowLeft + defaultWidth, windowTop + defaultHeight}
				set sidebar width of frontWindow to defaultSidebarWidth
				set tBar to toolbar visible of frontWindow
				set toolbar visible of frontWindow to not tBar
				set toolbar visible of frontWindow to tBar
			end try
		end repeat
	end if
end tell

 

Place the script in the ~/Library/Scripts/Applications/Finder/ folder and it will be available from the Script menu (if you have it enabled) in the menu bar.

When run, the script will give you the option of resizing just the front Finder window or all open Finder windows and will then size them to the default dimensions specified in the script.

There's also an option to set different defaults for each individual machine on your network. This assumes that you have set dedicated IP addresses for each machine and it's connected to your network. You'll need to change if localIP contains "xxx.xxx.x.xx" then to the appropriate IP address(es) of your machine(s).

NOTE: This is not an original script. I adapted it from one found elsewhere, though I can't remember where. But I credit the original author, whoever they are!

blog comments powered by Disqus