Re: How to list folder contents and show only certain file types ...
Re: How to list folder contents and show only certain file types ...
- Subject: Re: How to list folder contents and show only certain file types ...
- From: Gary Lists <email@hidden>
- Date: Mon, 02 Jun 2003 12:55:23 -0400
On or about 6/2/03 12:03 PM, Charles Heizer wrote:
>
Hello,
>
I'm trying to list the contents of a folder which I can do
>
successfully, but what I really want to show is only the files which
>
contain .jpg and .gif file extensions. I can not seem to get it to
>
work. Does anyone have an example of this they would be willing to
>
share?
>
>
Thanks,
>
>
- Charles
Hi Charles,
Seems there are two basic "kinds of ways" to approach that.
There is the extension approach (as you've suggested) and the file type
approach. Either may be more appropriate in situ. (X with extension, 9 by
type, etc.)
For me, using OS9, extension wouldn't be reliable, as many local files have
none (less true with images and net files than word processing and movie
files).
Anyway, here are two approaches that I tried, gritty direct from Smile:
-- get your files however you want
set imgFile to choose file of type "GIFf" -- just to get something
--> alias "My iMac:Documents:audio-book-tiny.gif"
set imgInfo to (info for imgFile)
To approach it by file type[1]:
if file type of imgInfo is "GIFf" then "type is GIFf"
--> "type is GIFf"
To approach it by name (getting name from info, as opposed to name from file
reference/alias)
if ".gif" is in name of imgInfo then ".gif in name"
--> ".gif in name"
HTH some little bit,
Gary
[1] I don't all the differences between |file type| and |file type
obsolete| or about the use of something like:
|extension| of imgInfo , which is used in the Apple cross-MacOS drop
templates and which seems not to error in OS9 except in one script I have.
'extension' is not a returned property of 'info for' here but I have several
drop scripts which don't seem to mind. (These are from the subroutines page
at Apple.)
The context of that use, in the Apple template, is this:
...
if (alias of the item_info is false) and [side-L BR]
((the file type of the item_info is in the type_list) or [side-L BR]
the |extension| of the item_info is in the extension_list) then
process_item(this_item)
...
--
OMM: OS9.1.2 / osa:AS 1.8.3 / osa:JS 1.0.3
"9 is Fine"
Please reply directly to the list.
Incoming messages are auto-deleted. (It's anti-spam, that's all.)
_______________________________________________
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.