Answered
Recursive function for getting files from folders
I want to search "indd" files from my whole directory (including subdirectories).
Arivu..
I want to search "indd" files from my whole directory (including subdirectories).
Arivu..
So it was -- the function is below. You call it like this:
var myFiles = ("/d/test" );It starts searching at the specified path and includes all subdirectories. It returns an array of file objects.
Peter
function find_files (dir)
{
return find_files_sub (dir, []);
}
function find_files_sub (dir, array)
{
var f = Folder (dir).getFiles ("*.*");
for (var i = 0; i < f.length; i++)
{
if (f instanceof Folder)
find_files_sub (f, array);
else
if (f.name.slice (-5).toLowerCase() == ".indd")
array.push (f);
}
return array;
}Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.