Re: Stupid Newbie Question
Re: Stupid Newbie Question
- Subject: Re: Stupid Newbie Question
- From: "Gary (Lists)" <email@hidden>
- Date: Mon, 18 Feb 2008 14:00:25 -0500
- Thread-topic: Stupid Newbie Question
"J. Downs" wrote:
> Hey, all. New to AppleScript, playing with Folder Actions, and need
> some help. Can anyone give me a clue as to why the following
> produces no discernible result?
An error is a discernible result. ;)
Your code throws an error, so I'm not sure why that isn't of some use to
you.
Error: Can't make name of alias "..." into type string.
What you can do, if you have file aliases like this, is to use the command
info for
That is, you can get the name (and other file info, as you ask about below)
from issuing a command like:
info for alias "..."
This will return a record, where 'name' is a property.
So, you can say:
name of (get info for alias "...")
I find it most convenient, when you know you will want more than one piece
of information, to get the whole 'info for' record into a variable, and then
use that to extract the interesting data:
set nfo to (get info for alias "...")
name of nfo
kind of nfo
etc.
> on adding folder items to this_folder after receiving added_items
>
> tell application "Finder"
> repeat with eachFile in added_items
> display dialog the name of eachFile buttons {"OK"} default button 1
> end repeat
> end tell
>
> end adding folder items to
>
> Additionally, I am trying to sort files by kind/type (folder, image,
> etc.), but can't find a listing of the values for this property that
> the Finder will recognize. Can someone point me to a comprehensive
> list?
I don't understand what you mean by "values for this property that the
Finder will recognize."
Or, maybe I think I understand. You only want to work on certain files, so
you have to filter all the added items.
This will probably need to take multiple forms, in order to adequately
filter.
The 'type identifier' is one way (this is returned from 'info for'), but
similar types of files can be associated with different UTI's. (A JPG can
be associated with Preview or with Photoshop or with...)
'file type' and 'file creator' are pretty much ignored these days, but they
shouldn't be. We should have that back in all files. <shrug>
You'll have to construct a filter of your own, to catch all the kinds of
things you will process, and that will necessarily take a rather ugly form,
by using a combination of 'type identifier' and 'kind' and other information
(like, probably most usefully) 'name extension'.
All of those are returned to you from the command 'info for', so I'll leave
it to you to work out your specifics.
(See the example applescript scripts that come with Mac OS X. One of those
is a droplet that processes dropped files, and it uses, IIRC, the 'name
extension' method...which I think is probably sufficient for most cases.)
--
Gary
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden