I have filtered a file list by file type using the AppleScript 
function in the Externals collection, which can be downloaded from

http://www.xworlds.com/metacard/

As far as I am aware, there is no way to do this without using 
AppleScript to find out the file type.  There has been some recent 
discussion of doing some AppleScript commands without using the 
external - check the list archives.

I've included a modified version of my filtering function below.  It 
basically goes through the file list and creates a new list of files 
that are either GIF, JPEG, or PICT files.  You can easily modify it 
to your needs.  You'll notice that I've jumped through some hoops to 
make sure the directory and file names are correct.  This is 
necessary because MetaCard uses the Unix standard "/" character as 
the separator in path names (replacing the Mac's ":").  It's more 
complicated on the Mac because Mac folder and file names can have "/" 
in them; in this case, MetaCard replaces "/" with ":" in file and 
directory names.


function macFilterList
                          #CREATE LAST PART OF APPLESCRIPT SCRIPT
   put "tell application " & quote & "Finder" & quote & return & \
       "set theType to the file type of theFile" & return & \
       "end tell" & return & \
       "return theType" into theASEnd
   put the files into macTempL
   put empty into theMacDirCont
   put the directory into theMacDir
   replace ":" with numToChar(23) in theMacDir
   replace "/" with ":" in theMacDir
   replace numToChar(23) with "/" in theMacDir
   set caseSensitive to true
   ext_asOpen                            #CALL TO THE EXTERNAL
   repeat for each line X in macTempL
     replace ":" with "/" in X
     put "set theFile to alias " & quote & theMacDir & ":" & X & quote &\
         return & theASEnd into theAScript       #CREATE THE 
APPLESCRIPT SCRIPT FOR A FILE
     ext_asCompileNexecute theAScript        #CALL TO THE EXTERNAL
     get the result
     replace quote with empty in it
     if (it = "GIFf") or (it = "JPEG") or (it = "PICT") then  #REPLACE 
WITH FILE TYPE YOU WANT
       put return & X after theMacDirCont
     end if
   end repeat
   set caseSensitive to false
   ext_asClose                            #CALL TO THE EXTERNAL
   delete line 1 of theMacDirCont
   return theMacDirCont
end macFilterList


Hope this helps.

Regards,
David Tremmel


>I am new to MetaCard so forgive me if there is an obvious answer. I 
>found that I can use the files() function to fetch a list of files 
>in a given folder. However, I can't figure out how to fetch or 
>select a list of files  of only certain type (I am talking 
>Macintosh). I found the fileType property but it seems to apply only 
>to files produced from MetaCard.
>
>RObert
>
>Archives: http://www.mail-archive.com/[email protected]/
>Info: http://www.xworlds.com/metacard/mailinglist.htm
>Please send bug reports to <[EMAIL PROTECTED]>, not this list.


Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to