Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
- Subject: Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
- From: Nigel Garvey <email@hidden>
- Date: Tue, 13 Apr 2004 22:51:43 +0100
Michael Terry wrote on Mon, 12 Apr 2004 13:54:22 -0700:
>
On Apr 12, 2004, at 7:10 AM, Nigel Garvey wrote:
>
> I myself am a great fan of what I call "bulk actions", such as were
>
> possible with pre-X versions of the Finder. They made possible some
>
> very
>
> fast, compact, and fun-to-write scripts.
>
>
Could you give an example or two, just for fun? I didn't script much
>
pre-X; I'd like to know what I'm missing.
Not quite compact, but very fast, fun to write, and a hoot to watch. :-)
It's a droplet that sets the view settings for the window of every folder
in the hierarchy of a dropped folder or folders. One or two of the
settings (I forget which - 'zoomed', at least) can only be done with the
window open. Instead of dealing with the window of the current folder in
the recursion, the script bulk-handles the windows of the folder's
subfolders. At the top level, the dropped folders are selected and are
bulk-handled under the 'selection' reference.
on open theList
-- Deal with the dragged, top-level folder(s) first
tell application "Finder"
activate
close every window -- just a precaution
tell Finder preferences
set listPrefs to ,
{shows comments, shows creation date, shows kind, shows label,
shows modification date, shows size, shows version}
set {shows comments, shows creation date, shows kind, shows
label, shows modification date, shows size, shows version} to ,
{false, false, false, false, true, false, false}
end tell
select theList -- to get it as a Finder reference
tell every folder of the selection
set theFolders to it
-- Open all the top level folders
-- and set their views, using the integer alternative for 'name'
open
tell its container window to set {has custom view settings, view,
zoomed} to {false, 2, true}
end tell
-- Now go through each top-level folder,
-- recursively bulk-handling its subfolders' windows
try
repeat with thisFolder in theFolders
my SetViews(thisFolder)
end repeat
on error
end try
tell Finder preferences
set {shows comments, shows creation date, shows kind, shows
label, shows modification date, shows size, shows version} to ,
listPrefs
end tell
end tell
end open
on SetViews(thisFolder)
tell application "Finder"
-- Open every subfolder of this folder (if any)
tell every folder of thisFolder
open
-- If any windows have opened, bulk-set their views
if the result is not {} then
-- 'It' is 'every folder of thisFolder'
tell its container window to set {has custom view settings,
view, zoomed} to {false, 2, true}
-- Close *every* window. (This seems to act faster than
-- specifically closing the windows of the open folders.
-- It doesn't affect popup windows.)
tell application "Finder" to close every window
-- Now deal with the subfolders of the subfolders
repeat with thisSubfolder in it
my SetViews(thisSubfolder)
end repeat
end if
end tell
end tell
end SetViews
NG
_______________________________________________
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.