Re: Scripting icon copying: Finder barfs - howcome?
Re: Scripting icon copying: Finder barfs - howcome?
- Subject: Re: Scripting icon copying: Finder barfs - howcome?
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 26 Feb 2001 11:40:34 -0800
On 2/26/01 10:52 AM, "Charles Arthur" <email@hidden> wrote:
>
Why doesn't this work? I'd like to automate some icon-copying and was
>
trying to do a demonstration of what I meant.
>
>
So of course it wouldn't work. Yet the Finder dictionary (9.0.4, AS 143,
>
inside leg 32) gives "item" as having "icon" as a property; and files get
>
inheritance from item.
>
>
Here's the scriptlet:
>
>
tell application "Finder"
>
choose file with prompt "Choose something with an icon to copy"
>
set theicon to icon of selection
>
choose file with prompt "Choose a file whose icon you want to change"
>
set thefile to icon of selection
>
activate
>
end tell
>
>
It keeps refusing to copy the icon and throws up various refusals,
>
sometimes at different points. What am I overlooking?
You didn't ask for a file, you asked for 'selection'. 'selection' in the
Finder is always a list, even if a single-item list. However, the result of
a 'choose file' is NOT 'selection' in the Finder, it's an alias (i.e. file
on the computer). So 'selection' is just muddling things here, because you
don't need it. (When you're starting out scripting and recorsing things in
the Finder, you see a lot of 'selection' because you have to keep selecting
things when you're recording, but not otherwise.) Are you sure you want to
set 'thefile' to the _icon_ ? it seems to me that this is what you might be
trying to do?
tell application "Finder"
choose file with prompt "Choose something with an icon to copy"
set theIcon to icon of result
set theFile to choose file with prompt "Choose a file whose icon you
want to change"
set icon of theFile to theIcon
activate -- you don't really need this
end tell
--
Paul Berkowitz