return array of folders only?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
berniebernie
Posts: 33
Joined: February 7th, 2005, 7:32 am
Contact:

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()));
??
Boom boom boom.
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

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
Post Reply