Cant get recursive search to work
Hello,
I need to do a recursive search and get all the files in all the directories from a root folder.I grabbed this adobe script from the forums.Unfortunately it doesnt work on line it gives me error 21: undefined not a object
if (f.name.slice(-4).toLowerCase() == ".jpg")so i narrowed it down to f.name is undefined i tried logging what type of variable it is using instanceof keyword but f isnt a Folder,File,or String type.Iam at a lost on were to go from here any help is appreciated thanks
function find_files (dir)
{
return find_files_sub (dir, []);
}
function find_files_sub (dir, array)
{
var f = (dir).getFiles ();
for (var i = 0; i < f.length; i++)
{
if (f instanceof Folder)
find_files_sub (f, array);
else
{
if(f instanceof Folder)
fileOut.writeln("Is Folder")
if(f instanceof File)
fileOut.writeln("Is File")
if(f instanceof String)
fileOut.writeln("Is String")
if (f.name.slice(-4).toLowerCase() == ".jpg")
array.push (f);
}
}
return array;
}