我正在尝试设置一个系统来搜索特定的文件类型,在本例中为.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])
}
}
}我不确定我哪里出错了
发布于 2013-01-19 08:16:52
它应该是这样的:
//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
https://stackoverflow.com/questions/14406478
复制相似问题