Page 1 of 1

return array of folders only?

Posted: October 10th, 2010, 9:27 am
by berniebernie
Hello coders!

I'm trying to use the getFiles method to make a list of folders and choose the last one modified. I understand that fileorfolderObject.modified() churns out a Date object which I can use, but I can't figure out how to make the getFile method to choose folders only.

The adobe guides specifies:
[mask]
Can also be the name of a function that takes a File or Folder object as its argument.
It is called for each file or folder found in the search; if it returns true, the object is added
to the return array.
Which is what I should be doing but can't figure out the syntax; right now I have:

Code: Select all

function returnFolderArray(location){
    fold = new Folder(location.toString());
    foldArray = fold.getFiles[b](function(){if (this instanceof File){return false}})
    return foldArray;
}
But it doesn't return anything. Help anybody?

Thanks for your time!



edit: well, it looks like i'm getting even more problems when I try to use the .modified() method; why does the debugger tell me that

Function Date is undefined

with this code:

Code: Select all

alert(typeof returnFolderArray(newLocation)[0].modified()));
??

Re: return array of folders only?

Posted: October 12th, 2010, 6:53 pm
by lloydalvarez
berniebernie wrote:Hello coders!

I'm trying to use the getFiles method to make a list of folders and choose the last one modified. I understand that fileorfolderObject.modified() churns out a Date object which I can use, but I can't figure out how to make the getFile method to choose folders only..
Can't test this rig now but this should do the trick:

Code: Select all

MyFolder.getFiles(returnOnlyFolders);

function returnOnlyFolders(f) { return f instanceof Folder; }
Lloyd