我正在尝试设置一个系统来搜索特定的文件类型,在这种情况下.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])
}
}
}
我不确定我哪里出错了
答案 0 :(得分:0)
抱歉,我在这里添加netPath var时更改了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