Skip navigation
michael.shen
Currently Being Moderated

How to traverse folders

Apr 11, 2012 6:34 PM

hello everyone,

 

can anybody help me how to traverse folders using scripting?

 

I want to compress a folder to a zip file using scripting.

 

thanks

 
Replies
  • Currently Being Moderated
    Apr 11, 2012 11:21 PM   in reply to michael.shen

    Seems Paul has answered a similar question a couple of threads down

    http://forums.adobe.com/thread/982318?tstart=0

    and referred to this thread

    http://forums.adobe.com/message/3568148#3568148

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2012 12:14 AM   in reply to michael.shen

    Sorry, my misunderstanding.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2012 12:51 AM   in reply to michael.shen

    This will leg a list of all files in each folder and sub folders...

     

     

    var folders =[];
    var topLevel = Folder.selectDialog("Please select top level folder");
    //get a list of all sub folders
    folders = FindAllFolders(topLevel, folders);
    folders.unshift(topLevel);
    for(var a in folders){
        //get a list of all files in each folder in turn
        var folderList = folders[a].getFiles();
        //do whatever to each file list
        }
    function FindAllFolders( srcFolderStr, destArray) {
     var fileFolderArray = Folder( srcFolderStr ).getFiles();
     for ( var i = 0; i < fileFolderArray.length; i++ ) {
      var fileFoldObj = fileFolderArray[i];
      if ( fileFoldObj instanceof File ) {   
      } else {
             destArray.push( Folder(fileFoldObj) );
      FindAllFolders( fileFoldObj.toString(), destArray );
      }
     }
     return destArray;
    }
    
    
     

     

    To get all files in one folder it would be ...

     

     

    var topLevel = Folder.selectDialog("Please select top level folder");
    topLevel.getFiles();
    
    
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2012 1:42 AM   in reply to michael.shen

    In the help in ExtendScript Toolkit you can use the Object Model Viewer and select Core JavaScipt Classes.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points