<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic List all files in a File Repository (TXW 9.1) in ThingWorx Developers</title>
    <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716846#M50883</link>
    <description>&lt;P&gt;I need an infotable that has the path &amp;amp; filenames of &lt;STRONG&gt;all the files&lt;/STRONG&gt; in a file repository, irrespective of the path.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Mar 2021 11:27:36 GMT</pubDate>
    <dc:creator>SB_9732186</dc:creator>
    <dc:date>2021-03-04T11:27:36Z</dc:date>
    <item>
      <title>List all files in a File Repository (TXW 9.1)</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716846#M50883</link>
      <description>&lt;P&gt;I need an infotable that has the path &amp;amp; filenames of &lt;STRONG&gt;all the files&lt;/STRONG&gt; in a file repository, irrespective of the path.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 11:27:36 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716846#M50883</guid>
      <dc:creator>SB_9732186</dc:creator>
      <dc:date>2021-03-04T11:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: List all files in a File Repository (TXW 9.1)</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716848#M50884</link>
      <description>&lt;P&gt;Did you try using BrowseFileSystem service of File Repository?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 11:40:01 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716848#M50884</guid>
      <dc:creator>mnarang</dc:creator>
      <dc:date>2021-03-04T11:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: List all files in a File Repository (TXW 9.1)</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716872#M50888</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/275134"&gt;@mnarang&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have used BrowseFileSystem but that doesn't fit my use case.&lt;/P&gt;
&lt;P&gt;Let me give you an example:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SB_9732186_0-1614844110980.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/38439iF5B49AFBFBFE9931/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SB_9732186_0-1614844110980.png" alt="SB_9732186_0-1614844110980.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The service should return an infotable:&lt;/P&gt;
&lt;P&gt;Path&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Filename&lt;/P&gt;
&lt;P&gt;/one&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;file1&lt;/P&gt;
&lt;P&gt;/one&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;file2&lt;/P&gt;
&lt;P&gt;/one&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;file3&lt;/P&gt;
&lt;P&gt;/two&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;file1&lt;/P&gt;
&lt;P&gt;/two&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;file2&lt;/P&gt;
&lt;P&gt;/two&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;file3&lt;/P&gt;
&lt;P&gt;/three&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; file1&lt;/P&gt;
&lt;P&gt;/three&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; file2&lt;/P&gt;
&lt;P&gt;/three&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; file3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 13:21:46 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716872#M50888</guid>
      <dc:creator>SB_9732186</dc:creator>
      <dc:date>2021-03-04T13:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: List all files in a File Repository (TXW 9.1)</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716890#M50889</link>
      <description>&lt;P&gt;Is it what you're looking for?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Unbenannt00.JPG" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/38445i95B88AC826C83B0D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Unbenannt00.JPG" alt="Unbenannt00.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var listFiles = Things[repoName].GetFileListingWithLinks({
   path: undefined /* STRING */,
   nameMask: undefined /* STRING */
});

var repoDirStructure = Things[repoName].GetDirectoryStructure();
for (var el in repoDirStructure.rows) {
   logger.warn("repoDirStructure"+repoDirStructure[el]["path"]);
   // Merging files from all subfolders
   if (el != 0){
      var listFiles2 = Things[repoName].GetFileListingWithLinks({
         path: repoDirStructure[el]["path"]
      });
   var params = {t1: listFiles, t2: listFiles2};
   listFiles = Resources["InfoTableFunctions"].Union(params);
   }
}
result = listFiles; &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Apr 2021 20:26:15 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716890#M50889</guid>
      <dc:creator>DmitryTsarev</dc:creator>
      <dc:date>2021-04-02T20:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: List all files in a File Repository (TXW 9.1)</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716893#M50890</link>
      <description>&lt;P&gt;I think direct API is not there for your use case, but you can use existing API to create your service which can give you desired result. For example, BrowseDirectory or BrowseFileSystem will give you everything which is there in the repo on path /, then you need to iterate the previous output and whenever you find fileType as D, you need to execute the service again to get file listing in the directories. At the end you need to have a logic for combining the data/representation as per your use case. There can be other combination as well like ListDirectories+ListFiles, as you will be iterating data and calling this API in the loop, you need to test this solution from performance standpoint.&lt;/P&gt;
&lt;P&gt;One more point if you have huge hierarchy of directories then this approach might not work, as you have to deep dive in the directories and execute the service in inner loops.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 14:29:21 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716893#M50890</guid>
      <dc:creator>mnarang</dc:creator>
      <dc:date>2021-03-04T14:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: List all files in a File Repository (TXW 9.1)</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716896#M50891</link>
      <description>&lt;P&gt;if the approach mentioned by&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/946"&gt;@DmitryTsarev&lt;/a&gt;&amp;nbsp;works for you, then it is good as it seems to be more simpler and straight forward.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 14:31:24 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716896#M50891</guid>
      <dc:creator>mnarang</dc:creator>
      <dc:date>2021-03-04T14:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: List all files in a File Repository (TXW 9.1)</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716903#M50893</link>
      <description>&lt;P&gt;The one above was a quick and dirty code.&lt;/P&gt;
&lt;P&gt;Here is the sleeker version (no "init" step in the beginning and thus no "if" inside the loop):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var params = {
   infoTableName: "listFiles",
   dataShapeName: "FileSystemFileWithLinks"
};
var listFiles = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

var repoDirStructure = Things[repoName].GetDirectoryStructure();

for (var el in repoDirStructure.rows) {
   logger.warn("repoDirStructure"+repoDirStructure[el]["path"]);
   // Merging files from all subfolders
   var listFiles2 = Things[repoName].GetFileListingWithLinks({
      path: repoDirStructure[el]["path"]
   });
   var params = {t1: listFiles, t2: listFiles2};
   listFiles = Resources["InfoTableFunctions"].Union(params);
}
result = listFiles;&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 05 Mar 2021 14:27:27 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/716903#M50893</guid>
      <dc:creator>DmitryTsarev</dc:creator>
      <dc:date>2021-03-05T14:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: List all files in a File Repository (TXW 9.1)</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/717117#M50919</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/946"&gt;@DmitryTsarev&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The codes that you have provided will only work for a 2-level directory structure, am I correct?&lt;/P&gt;
&lt;P&gt;I need it for n-level directory structure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 10:57:19 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/717117#M50919</guid>
      <dc:creator>SB_9732186</dc:creator>
      <dc:date>2021-03-05T10:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: List all files in a File Repository (TXW 9.1)</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/717165#M50922</link>
      <description>&lt;P&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/365375"&gt;@SB_9732186&lt;/a&gt;&amp;nbsp;It works for arbitrary directory hierarchy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code gets the hierarchy from the GetDirectoryStructure and then just iterates over it. Here is the InfoTable returned by GetDirectoryStructure.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Unbenannt00.JPG" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/38502iA5319CC168DF63E7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Unbenannt00.JPG" alt="Unbenannt00.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here is a bit better commented code &lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt; &lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;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;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;The final result returned by the service:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Unbenannt01.JPG" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/38503i3652A310F0B99E03/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Unbenannt01.JPG" alt="Unbenannt01.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 14:25:59 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/717165#M50922</guid>
      <dc:creator>DmitryTsarev</dc:creator>
      <dc:date>2021-03-05T14:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: List all files in a File Repository (TXW 9.1)</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/719111#M51087</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/365375"&gt;@SB_9732186&lt;/a&gt;.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;If you feel your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Regards.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;--Sharon&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 21:02:03 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/List-all-files-in-a-File-Repository-TXW-9-1/m-p/719111#M51087</guid>
      <dc:creator>slangley</dc:creator>
      <dc:date>2021-03-16T21:02:03Z</dc:date>
    </item>
  </channel>
</rss>

