Solved
List all files in a File Repository (TXW 9.1)
I need an infotable that has the path & filenames of all the files in a file repository, irrespective of the path.
I need an infotable that has the path & filenames of all the files in a file repository, irrespective of the path.
The code gets the hierarchy from the GetDirectoryStructure and then just iterates over it. Here is the InfoTable returned by GetDirectoryStructure.
Here is a bit better commented code 🙂
var params = {
infoTableName: "listFiles",
dataShapeName: "FileSystemFileWithLinks"
};
// Initializing empty InfoTable with the appropriate shape
var listFiles = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
// Getting the directory structure of the repo
var repoDirStructure = Things[repoName].GetDirectoryStructure();
// Iterating through all the directories in the repo
// and merging the list of files in each
for (var el in repoDirStructure.rows) {
var listFiles2 = Things[repoName].GetFileListingWithLinks({
path: repoDirStructure[el]["path"]
});
var params = {t1: listFiles, t2: listFiles2};
listFiles = Resources["InfoTableFunctions"].Union(params);
}
result = listFiles;
The final result returned by the service:
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.