Re: Problems with speed & "Info For"
Re: Problems with speed & "Info For"
- Subject: Re: Problems with speed & "Info For"
- From: Kai Edwards <email@hidden>
- Date: Wed, 30 Jan 2002 19:38:18 +0100
on 29/1/02 7:12 pm, Brian Johnson at email@hidden wrote:
>
>
On Tue, 29 Jan 2002, Kai Edwards wrote:
>
>
>> Date: Sun, 27 Jan 2002 21:34:51 +1100
>
>> From: Shane Stanley <email@hidden>
>
>>
>
>> Keep in mind that "folder of info for" is highly dependent on how many files
>
>> are in the folder and its subfolders; big folders can take a long time.
>
>
>
> Wow! - You're not kidding, are you Shane?
>
>
I've been following this discussion somewhat closely, as I have a fairly
>
mature script that works well enough, but I'm now trying to speed up. It
>
walks a folder hierarchy of HTML files, building links between them. In
>
the process I use "Info For" on just about every file in the hierarchy,
>
which probably accounts for some of the speed problems. The thing is, the
>
script has to detect folders (ends with ":" looks good here) and aliases
>
to folders (alias of info for ..) and file types (file type of info
>
for...) all of which involves at least one call to "Info for". The
>
"Galapagos Suite" in Tanaka's OSAX looks promising for some of this, but
>
are there other 'classic' ways (like "ends with") to avoid "Info for"?
One vanilla possibility that springs to mind is:
tell application "Finder"
kind of theItem
end tell
-- where 'theItem' is a reference to a Finder item (disk/folder/file).
You need to tell the Finder to make this call - since 'kind' is a property
of the Finder's class 'item'. You can locate more information about this and
other properties under 'item' in the Finder dictionary.
Depending on what 'theItem' is, something like one of the following strings
should be returned:
"disk"
"folder"
"alias"
"control panel"
"system extension"
"application program"
"document" --(generic)
"SimpleText document"
"Microsoft Word document"
"Microsoft Excel document"
"FileMaker Pro document"
"FreeHand document"
"Director document"
etc...
Hopefully, your script already specifies a path to each 'theItem' involved
in your analysis. If you just use 'choose file' and select a file alias, the
path to the original file will be returned - and 'kind' will therefore not
return the expected string, "alias". (A similar result occurs when an alias
is dropped onto a droplet.)
In addition, quite what speed comparisons might be involved here, I hesitate
to speculate - especially after our discussions about 'info for'! The
structure of your filing system will undoubtedly have a bearing on the
results. If you need to use repeat loops significantly (and from the sound
of it, I suspect you probably do) - you may find all those calls to the
Finder quite time-consuming.
The best way forward may be to dip your toe in the water with a few short,
comparative tests - before diving in headfirst with a full-blown script.
As for getting 'file type' in the form returned by 'info for', I can't (off
the top of my head) think of an obvious vanilla alternative. However, if one
does exist, I'm sure my admission of ignorance will attract some suggestions
from those with greater experience in these matters! ;)
There's also another question worth considering - the answer to which will
clearly depend on how you use the 'file type' information: Would the
descriptive strings returned by 'kind' (like the examples listed above) be
remotely useful as a substitute for 'file type'?
You can also use 'kind' as a filter for Finder objects (although you'd still
need to tunnel through subfolders to do this). For example:
set theDocs to items of theFolder whose kind contains "document"
set theMSDocs to items of theFolder whose kind contains "Microsoft"
set theAliases to items of theFolder whose kind = "alias"
- and so on (again, see the list of examples above for clues on the
possibilities).
Finally, if you have some influence/control over the machines on which your
solution will be run, don't completely rule out scripting additions. While I
usually stick to vanilla for general distribution, I recommend a small core
of OSAX 'gems' to my major clients - so they can benefit from the enhanced
functionality and performance when it really matters.
HTH
Kai
PS:
Apologies for delayed response. Server problems put me back 24 hours. :(
--
**********************************
Kai Edwards Creative Resources
1 Compton Avenue Brighton UK
Telephone +44 (0)1273 326810
**********************************