function getAllFiles(folderName,houzhui){ folderName var regthis = new RegExp( '.+.('+houzhui+')$','i'); var inFolder = new Folder(folderName) var fileList = null if(inFolder != null){ var fileList = inFolder.getFiles(regthis); } return fileList } files = getAllFiles('dirPath','jpg') files2 = getAllFiles('dirPath2','jpg|png')