title: Searching for a specific filetype in a folder based on its parent folder
body: <p>I'm trying to set up a system to search for specific files types, in this case .aep, in folders that will change over time</p>
  
  <p>example in a folder called MER is a folder called Mermaid_v03 when this file is updated another department it will become Mermaid_v04 so hard coding the address isn't an option. </p>
  
  <p>So the parent folder always contains the first three letters of folder containing the aep I need in capital letters. I've written the following. </p>
  
  <pre><code>//Get the last folder name in the path
  var netPath =Folder("//networkpath/MER")
  var justName = charFileLoc.substring(charFileLoc.lastIndexOf("/")+1);
  
  var FolderItems = netPath.getFiles();
  
  for (x = 0; x &lt; FolderItems.length; x++) {
  
  
  //Search for aep
  if (FolderItems[i].name.match(justName)) {
  
      alert("I see a folder that starts with "+justName);  
      var matchFolder = Folder(FolderItems[i]); 
  
           for (x = 0; x &lt; matchFolder.length; x++) {
  
              //Search new folder for aep
              if (matchFolder[i].name.match(/\.(aep)$/)){
  
                  alert("I see an aep file called "+matchFolder[i])
                 }
              }
         }
  </code></pre>
  
  <p>I'm not sure where I went wrong</p>