Listing files in a folder
Rishi Viner
rishi at puredata.com.au
Thu Oct 27 19:20:19 EDT 2005
Wow! Some days you just don't know how lucky you will be! :)
I'm about to start on an in-house project using rev that will also need to
keep track of and move lots of files around. Thanks Sarah!
Rishi Viner.
Quoting Sarah Reichelt <sarah.reichelt at gmail.com>:
> Hi All,
>
> I got sick of listing files in various folders and having to set the
> default folder to do so, and then having to remember to set it back
> afterwards. You can't use "the files" to list files in anything other
> than the default folder, so here is the function I wrote to handle
> this boring stuff for me. It may be of no interest to most people, but
> I am currently working on an app that has to examine multiple folders
> and transfer files around, so it is saving me a lot of typing.
>
> The first parameter is the path to a folder. The second parameter
> dictates whether the full file path for each file should be returned,
> or just the file name. It can be any of true, yes or full.
>
> Cheers,
> Sarah
>
>
> 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
> _______________________________________________
> 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
>
--
Rishi Viner
PUREDATA
www.puredata.com.au
More information about the use-livecode
mailing list