How do I close finder windows? Here’s what I have so far:
tell application “Finder”
if the (count of windows) is not 0 then
set collapsed of every window to true
end if
end tell
This gets them off my desktop, but adds them to the doc. I want to close them altogether. I tried “set visible of every window to false” but that didn’t work.
Now that I’ve got them to close, how do I open new ones? I built a function to do it, but it’s not working? I suspect it has something to do with my path syntax, but I can’t figure it out. Here’s what I’ve got:
on openWindow(windowPath, windowBounds)
open windowPath
set currentWindow to window 1
set bounds of currentWindow to windowBounds
end openWindow
tell application “Finder”
if the (count of windows) is not 0 then
close every window
end if
end tell
You don’t have to check first for open windows, just issue the close command. As to your handler for opening folders, well, it needs to be in a Finder tell block, you need to pass paths, not strings (which is easy of for the two paths you want because the Finder gives you easy constants for those paths), you didn’t specify what type of view you want, you need to be specific as to Finder windows (as opposed to get info windows, a copy window, etc.), and there are other parameters you can specify such as whether to show the toolbar, which columns to show, etc. This code should help:
Okay, one last stupid, prize-winning question – is it possible to organize files on the desktop – arranges by date? So far I’ve tried (within tell application “FInder” blocks):
arrange by name
arrange by “name”
sort by name
organize by name
clean up by name
… and several others I can’t remember. I imagine it’s a simple solution, but I can’t figure it out. I did discover that the finder dictionary states that “sort” is “not available yet.” Does that mean it can’t be done? BTW, I find the dictionaries to be somewhat cryptic.