Re: How do I close a Finder folder window?
Re: How do I close a Finder folder window?
- Subject: Re: How do I close a Finder folder window?
- From: Mr Tea <email@hidden>
- Date: Wed, 28 Aug 2002 12:55:52 +0100
This from Joel May - dated 28-8-02 10.16 am:
>
I can open a finder window just fine, but when I try to close it, I get
>
an error.
That's because your script is trying to close the folder, not the window.
In pre OS X systems you can identify the window you want to close by index
(numerical value of window in stacking order, 1 being frontomost), or by
name. (Eg: 'close window 1'; 'close window "My Stuff"')
In OS X and up, you can also identify a Finder window by ID or target. The
ID seems to be the Finder's preferred way of keeping track of open windows
and is not much use to you in this context, while the target is the actual
folder being displayed in the window, including full path. You can use
'close Finder window 1', 'close Finder window "My Stuff"', or for ultimate
precision, you can do something like this...
tell application "Finder"
set theWindows to every Finder window
repeat with w in theWindows
if target of w as alias is alias "HD:Users:home:My Stuff" then close w
end repeat
end tell
NB - With the advent of OS X the separation between folders and windows has
become more explicit. Finder Windows are now 'viewers' that can show the
contents of any folder or disk, rather than being tied to a specific folder.
(So now you can use a single window to display any folder you want, or point
several windows at the same folder.)
HTH
Nick
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.