<?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 Script Property Value list referencing a filename list in a directory in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-property-value-list-referencing-a-filename/m-p/188542#M14488</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there anyway that my value list for a sys.argv could be a dynamic list of filenames from a directory?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want the user to be able to only select files that exist and automatically include new files to the list as I create them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The filename forms part of an appended text file that is ude by an external process.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Andrew Tucker&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;HVP Plantations&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Victoria&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Australia&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Aug 2012 22:31:23 GMT</pubDate>
    <dc:creator>andrewtucker</dc:creator>
    <dc:date>2012-08-30T22:31:23Z</dc:date>
    <item>
      <title>Script Property Value list referencing a filename list in a directory</title>
      <link>https://community.esri.com/t5/python-questions/script-property-value-list-referencing-a-filename/m-p/188542#M14488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there anyway that my value list for a sys.argv could be a dynamic list of filenames from a directory?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want the user to be able to only select files that exist and automatically include new files to the list as I create them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The filename forms part of an appended text file that is ude by an external process.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Andrew Tucker&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;HVP Plantations&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Victoria&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Australia&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 22:31:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-property-value-list-referencing-a-filename/m-p/188542#M14488</guid>
      <dc:creator>andrewtucker</dc:creator>
      <dc:date>2012-08-30T22:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Script Property Value list referencing a filename list in a directory</title>
      <link>https://community.esri.com/t5/python-questions/script-property-value-list-referencing-a-filename/m-p/188543#M14489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Andrew,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are using your script within a toolbox you can do this using the Tool Validation tab.&amp;nbsp; You would set a parameter (i.e. Input) under the Parameters tab of the script's Properties.&amp;nbsp; The Data Type for this parameter would be 'String'.&amp;nbsp; You can then update the initializeParameters function with the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def initializeParameters(self): &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = r"C:\temp\python\test.gdb" &amp;nbsp;&amp;nbsp;&amp;nbsp; list = [] &amp;nbsp;&amp;nbsp;&amp;nbsp; lstFCs = arcpy.ListFeatureClasses("*") &amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in lstFCs: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list.append(fc) &amp;nbsp;&amp;nbsp;&amp;nbsp; stringFilter = self.params[0].filter &amp;nbsp;&amp;nbsp;&amp;nbsp; stringFilter.list = list &amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You will want to change the 'arcpy.env.workspace' to your desired workspace.&amp;nbsp; You will also need to update 'arcpy.ListFeatureClasses' if you are working with another data type (i.e. rasters, tables).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Aug 2012 12:33:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-property-value-list-referencing-a-filename/m-p/188543#M14489</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-08-31T12:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Script Property Value list referencing a filename list in a directory</title>
      <link>https://community.esri.com/t5/python-questions/script-property-value-list-referencing-a-filename/m-p/188544#M14490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Andrew,&lt;BR /&gt;&lt;BR /&gt;If you are using your script within a toolbox you can do this using the Tool Validation tab.&amp;nbsp; You would set a parameter (i.e. Input) under the Parameters tab of the script's Properties.&amp;nbsp; The Data Type for this parameter would be 'String'.&amp;nbsp; You can then update the initializeParameters function with the following:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def initializeParameters(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = r"C:\temp\python\test.gdb"
&amp;nbsp;&amp;nbsp;&amp;nbsp; list = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; lstFCs = arcpy.ListFeatureClasses("*")
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in lstFCs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list.append(fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; stringFilter = self.params[0].filter
&amp;nbsp;&amp;nbsp;&amp;nbsp; stringFilter.list = list
&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;You will want to change the 'arcpy.env.workspace' to your desired workspace.&amp;nbsp; You will also need to update 'arcpy.ListFeatureClasses' if you are working with another data type (i.e. rasters, tables).&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll give that a try now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT: Works like a charm!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:31:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-property-value-list-referencing-a-filename/m-p/188544#M14490</guid>
      <dc:creator>andrewtucker</dc:creator>
      <dc:date>2021-12-11T09:31:01Z</dc:date>
    </item>
  </channel>
</rss>

