Getting list of files in a folder

Mark Swindell mdswindell at cruzio.com
Tue Feb 9 00:20:58 EST 2010


Terry, Sarah,

Wow, that was fast!  Thank you so much.

Mark

On Feb 8, 2010, at 9:19 PM, Sarah Reichelt wrote:

> On Tue, Feb 9, 2010 at 3:05 PM, Mark Swindell <mdswindell at cruzio.com> wrote:
>> How do I return a list of the files in a given folder on disk along with their full path?
> 
> Manually :-)
> 
> Here is a function I wrote that lists files in a folder for you,
> resetting the defaultFolder when it's got the list.
> 
> function listFiles pFolder, pGiveFullPath
>  if there is not a folder pFolder then return empty
> 
>  -- get the list of files & reset default folder
>  put the defaultFolder into tOldDefault
>  set the defaultFolder to pFolder
>  put the files into tFileList
>  set the defaultFolder to tOldDefault
> 
>  -- filter out OS X's invisible files
>  filter tFileList without ".*"
> 
>  -- add folder path to file name if required
>  if pGiveFullPath is among the items of "true,yes,full" then
>    put empty into tFullList
>    if the last char of pFolder <> "/" then put "/" after pFolder
>    repeat for each line L in tFileList
>      put pFolder & L & cr after tFullList
>    end repeat
>    delete last char of tFullList
>    return tFullList
> 
>  else
>    return tFileList
>  end if
> end listFiles
> 
> 
> If you use:
>   put listFiles(tFolder) into fld "Files"
> you get tust the file names, but if you use:
>   put listFiles(tFolder, "full") into fld "Data"
> you will get the full file paths.
> 
> Cheers,
> Sarah
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list