<?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 Access multiple folders simultaneously (VBA) in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/access-multiple-folders-simultaneously-vba/m-p/263110#M6755</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a loop that adds two layers in every step, and both layers are from different folders. That means that the loop involves going through two different folders simultaneously. I know how to loop through one folder but don't know how to do it for multiple folders.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Following is what I want to do:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
inputfile1 = Dir(folder1 + "*.shp")
inputfile2 = Dir(folder2+"*.shp")

do while inputfile1 &amp;lt;&amp;gt; ""
&amp;nbsp; ' Add inputfile1 and inputfile2 to map

&amp;nbsp; ' go to next files in respective folders
&amp;nbsp; inputfile1=Dir
&amp;nbsp; inputfile2=Dir
Loop
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Nagendra&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Nov 2011 04:44:21 GMT</pubDate>
    <dc:creator>NagendraDhakar</dc:creator>
    <dc:date>2011-11-09T04:44:21Z</dc:date>
    <item>
      <title>Access multiple folders simultaneously (VBA)</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/access-multiple-folders-simultaneously-vba/m-p/263110#M6755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a loop that adds two layers in every step, and both layers are from different folders. That means that the loop involves going through two different folders simultaneously. I know how to loop through one folder but don't know how to do it for multiple folders.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Following is what I want to do:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
inputfile1 = Dir(folder1 + "*.shp")
inputfile2 = Dir(folder2+"*.shp")

do while inputfile1 &amp;lt;&amp;gt; ""
&amp;nbsp; ' Add inputfile1 and inputfile2 to map

&amp;nbsp; ' go to next files in respective folders
&amp;nbsp; inputfile1=Dir
&amp;nbsp; inputfile2=Dir
Loop
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Nagendra&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2011 04:44:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/access-multiple-folders-simultaneously-vba/m-p/263110#M6755</guid>
      <dc:creator>NagendraDhakar</dc:creator>
      <dc:date>2011-11-09T04:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: Access multiple folders simultaneously (VBA)</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/access-multiple-folders-simultaneously-vba/m-p/263111#M6756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would add the files in the two folders into two separate lists, and then iterate through the lists.&amp;nbsp; Be careful if the number of files in the two folders is not the same.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Sub RunMe()
&amp;nbsp; Dim folder1 As String
&amp;nbsp; folder1 = "C:\some_files\"
&amp;nbsp; Dim folder2 As String
&amp;nbsp; folder2 = "C:\more_files\"
&amp;nbsp; 
&amp;nbsp; Dim fileList1 As Collection
&amp;nbsp; Set fileList1 = GetShapefilesInFolder(folder1)
&amp;nbsp; Dim fileList2 As Collection
&amp;nbsp; Set fileList2 = GetShapefilesInFolder(folder2)
&amp;nbsp; 
&amp;nbsp; Dim i As Long
&amp;nbsp; Dim count As Long
&amp;nbsp; If fileList1.count &amp;gt; fileList2.count Then
&amp;nbsp;&amp;nbsp;&amp;nbsp; count = fileList1.count
&amp;nbsp; Else
&amp;nbsp;&amp;nbsp;&amp;nbsp; count = fileList2.count
&amp;nbsp; End If
&amp;nbsp; 
&amp;nbsp; For i = 1 To count
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Add files to map
&amp;nbsp;&amp;nbsp;&amp;nbsp; If i &amp;lt;= fileList1.count Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print "1: " &amp;amp; fileList1.Item(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp;&amp;nbsp;&amp;nbsp; If i &amp;lt;= fileList2.count Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print "2: " &amp;amp; fileList2.Item(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp; Next

End Sub

Private Function GetShapefilesInFolder(folder As String) As Collection
&amp;nbsp; Dim files As New Collection
&amp;nbsp; 
&amp;nbsp; Dim file As String
&amp;nbsp; file = Dir(folder &amp;amp; "*.shp")
&amp;nbsp; Do While file &amp;lt;&amp;gt; ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; files.Add (file)
&amp;nbsp;&amp;nbsp;&amp;nbsp; file = Dir
&amp;nbsp; Loop

&amp;nbsp; Set GetShapefilesInFolder = files
End Function
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:53:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/access-multiple-folders-simultaneously-vba/m-p/263111#M6756</guid>
      <dc:creator>TimWhiteaker</dc:creator>
      <dc:date>2021-12-11T12:53:59Z</dc:date>
    </item>
  </channel>
</rss>

