Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Create Array of all filenames in target folder on desktop using ExtendScript?

New Here ,
Nov 25, 2014 Nov 25, 2014

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!

TOPICS
Scripting
6.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 25, 2014 Nov 25, 2014

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

Translate
Community Expert ,
Nov 25, 2014 Nov 25, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 25, 2014 Nov 25, 2014

Excellent, that did the trick!

Thank you Dan!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 20, 2015 Oct 20, 2015

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 20, 2015 Oct 20, 2015
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines