Re: Problems with speed & "Info For"
Re: Problems with speed & "Info For"
- Subject: Re: Problems with speed & "Info For"
- From: Nigel Garvey <email@hidden>
- Date: Wed, 30 Jan 2002 00:12:20 +0000
Brian Johnson wrote on Tue, 29 Jan 2002 10:12:34 -0800 (PST):
>
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"?
You could try tackling the problem the other way round. Instead of
testing every item to see what it is, you could get the Finder to provide
you with items of the type that interest you - or ignore those that don't
- in bulk. For example:
tell application "Finder"
set subfolders to thisFolder's folders
set aliasFiles to thisFolder's alias files
set otherFiles to thisFolder's files whose kind is not "alias"
set fredFiles to thisFolder's files whose file type is in {"fred",
"fr*d"}
-- etc.
'Info for' is only slow when has to research the size of large folders or
folder hierarchies. Pre-filtering with the Finder narrows the range of
items you need to examine. It's not guaranteed to make any particular
script faster, but there may be some criterion that would do so your
script.
NG