Filtering FIle Types

Peter M. Brigham pmbrig at gmail.com
Tue Sep 2 13:50:28 EDT 2014


Here's an expanded version -- feed it a list of filetypes and get them all at once:

function filterByType pFileList, pTypeList
   -- assuming pTypeList is of the form "jpg,png,gif" (for instance)
   repeat for each item t in pTypeList
      put pFileList into workingList
      filter workingList by ("*." & t)
      put workingList & cr after outList
   end repeat
   return char 1 to -2 of outList
end filterByType

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig


On Sep 2, 2014, at 1:14 PM, JB wrote:

> Thank you for the reply and code.
> 
> If I call it for every type I want then
> I will need to splice it back together
> with the other types I filtered after I
> am done calling for each type.
> 
> I guess there comes a point when I
> have added a certain amount of types
> it will be faster to do one line at a time.
> 
> Thank you for the code!
> 
> John Balgenorth
> 
> 
> On Sep 2, 2014, at 5:17 AM, Peter M. Brigham <pmbrig at gmail.com> wrote:
> 
>> you can use the following:
>> 
>> function filterByType pFileList, pType
>>  -- assuming pType is of the form "jpg" or "png"
>>  filter pFileList by ("*." & pType)
>>  return pFileList
>> end filterByType
>> 
>> and call it repeatedly for whatever file types you want.
>> 
>> -- Peter
>> 
>> Peter M. Brigham
>> pmbrig at gmail.com
>> http://home.comcast.net/~pmbrig
>> 
>> 
>> On Sep 1, 2014, at 4:28 PM, JB wrote:
>> 
>>> I have not tried it yet but if it works
>>> the problem is I might want to use
>>> a variety of file types so the repeat
>>> would filter one line at a time and
>>> then you check for that type in the
>>> list of types you will allow.
>>> 
>>> The way you provided would need it
>>> to allow a list of types or I would need
>>> to keep filtering so there might be a
>>> faster way but I am not sure.
>>> 
>>> Thank you for the reply and code advice.
>>> 
>>> John Balgenorth
>>> 
>>> 
>>> On Sep 1, 2014, at 1:24 PM, Martin Koob <mkoob at rogers.com> wrote:
>>> 
>>>> 
>>>> I think you can use the filter command with a wildcard and your extension. 
>>>> Put your folder path into tMyFolderPath then:
>>>> 
>>>> set the folder to tMyFolderPath
>>>> put the files into theFiles
>>>> filter theFiles with "*.jpg"
>>>> 
>>>> Martin
>>>> 
>>>> 
>>>> 
>>>> --
>>>> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Filtering-FIle-Types-tp4682777p4682778.html
>>>> Sent from the Revolution - User mailing list archive at Nabble.com.
>>>> 
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> use-livecode at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>> 
>>> 
>>> 
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list