Copy link to clipboard
Copied
I'm trying to write a script that will look at a target folder on my computer and grab the file paths for each of the files inside that folder and then store them in an array. This array will then be accessed later to add individual file paths into target comps. So far I have been unsuccessful at figuring out how to accomplish this, is it possible to tell ExtendScript to create an array based on a finder folder's contents?
Thanks!
1 Correct answer
Once you have the folder, this will give you an array of all the files (and folders) in the folder:
var myFiles = myFolder.getFiles();
Dan
Copy link to clipboard
Copied
Once you have the folder, this will give you an array of all the files (and folders) in the folder:
var myFiles = myFolder.getFiles();
Dan
Copy link to clipboard
Copied
Excellent, that did the trick!
Thank you Dan!
Copy link to clipboard
Copied
Is there a way to get the contents (files) of all folders in a parent directory?
I'm using the above solution this way:
// define file names we're looking for
var maskIdentifier = "*_V.png";
// define folder for the config image files
var configFolder = Folder("/c/Production/Automotive/images/configs/");
// create list of files
var fileList = configFolder.getFiles (maskIdentifier);
But that only gives me the parent directory. I have folders with multiple subdirectories wherein the files matching the maskIdentifier for getFiles may be.
configs\Folder1\Subfolder1\
configs\Folder1\Subfolder2\
configs\Folder2\Subfolder1\
configs\Folder2\Subfolder2\
...etc
Any help would be appreciated.
Copy link to clipboard
Copied
getFiles() actually get everything: files and folders, but immediate children only. To get deeper, you'd have to reapply getFiles, in a way or another, to the children folders.