2

我正在尝试设置一个系统来搜索特定文件类型,在本例中为 .aep,在随时间变化的文件夹中

例如,在名为 MER 的文件夹中是名为 Mermaid_v03 的文件夹,当此文件更新到另一个部门时,它将变为 Mermaid_v04,因此无法对地址进行硬编码。

所以父文件夹总是包含文件夹的前三个字母,其中包含我需要的大写字母 aep。我写了以下内容。

//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 < 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 < matchFolder.length; x++) {

            //Search new folder for aep
            if (matchFolder[i].name.match(/\.(aep)$/)){

                alert("I see an aep file called "+matchFolder[i])
               }
            }
       }

我不确定我哪里出错了

4

1 回答 1

0

抱歉,我在此处添加 netPath var 时更改了它,以使其更易于理解。应该是这样的:

//Get the last folder name in the path
var charFileLoc =Folder("//networkpath/MER")
// Grab just the last folder name
var justName = charFileLoc.substring(charFileLoc.lastIndexOf("/")+1);

var FolderItems = charFileLoc.getFiles();

for (x = 0; x < 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 < matchFolder.length; x++) {

            //Search new folder for aep
            if (matchFolder[i].name.match(/\.(aep)$/)){

                alert("I see an aep file called "+matchFolder[i])
               }
            }
       }

我最大的问题是使用 justName 以不区分大小写的方式搜索文件夹的开头。目前我相信它正试图与 MER 完全匹配。此外,当我尝试检查 FolderItems 中列出的文件时,它们没有正确显示名称,它们都被命名为 ds_store

于 2013-01-19T00:16:51.817 回答