I’ve been working around a strange bug in the Mac OS X Finder with an
AppleScript for quite some time now. Most users don’t notice the bug at all, but
I do. Rather than describe it, follow these steps and see it for yourself:
- Make a new Finder window
- Set its view style to column
- Adjust the column width/s with the slider, making them wider together
- Leave the window open and log out
- Log back in
At this point, your window will be open, but its columns will be at their
default widths.
- Close that window
- Open a new Finder window (should default to column view now)
Now, you’ll see your custom widths respected. It just seems to affect the first
window you make or see that’s in column view.
This bothers me, honestly, and I wrote a tiny–and really
dim-witted–AppleScript to get around the problem. Here it is (works best when
run at login automatically):
on run
tell application "Finder"
if (count of windows) is greater than 0 then
-- do nothing
else if (count of windows) is equal to 0 then
set fix to (make new Finder window)
close fix
end if
end tell
end run
As I said, it’s not a smart script at all. If you have columned windows open, it
leaves them there for you to deal with. Wanting to make the script smarter, I
came up with this:
on run
tell application "Finder"
if (count of windows) is greater than 0 then
set daWindows to (every Finder window whose current view is column view) as list
set daStop to 1
repeat until daStop = ((count of items in daWindows) + 1)
set reopenMe to item daStop of daWindows
set helloPath to (target of reopenMe)
set daPosition to position of reopenMe
close reopenMe
set newWindow to (make new Finder window at helloPath)
set position of newWindow to daPosition
set daStop to (daStop + 1)
end repeat
else if (count of windows) is equal to 0 then
set fix to (make new Finder window)
close fix
end if
end tell
end run
This works almost as it should. (And it’s probably more complex than it needs
to be.) Where it fails is best described in this manner:
You leave a columned window open to “/Applications/Utilities”, and cycle through
a log out/log in to see the script run. Well, it’ll deal with the window without
closing the non-columned windows, but when the dealt-with window is recreated,
it doesn’t point to “/Applications/Utilities”.
Here’s where I’m stumped. I can’t figure out why the code I wrote doesn’t work,
and I’m starting to think it’s a bug in either the Finder or AppleScript (or
both). Shouldn’t “make new Finder window at helloPath” work after setting
helloPath to “target of reopenMe”?
What, if anything, am I missing?
Any help is appreciated.
-/-
Michael Watson
mike@milesmedia.net
[url=http://www.mikey-san.net/]http://www.mikey-san.net/[/url]