<?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 arcpy Describe lyrx data source in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-describe-lyrx-data-source/m-p/1363617#M69463</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a relatively simple script that describes the data source and folder for lyrx files. The script worked fine in ArcMap but I am reformatting it for Pro and can't get the same output as the Arcmap script had. The script works if the lyrx is being sourced from a geodatabase or an arcgis server service. However, if the data is being sourced from an enterprise geodatabase, it gives me a temporary directory, based on whichever user is running the script. Any ideas how I can get the entire SDE path instead of the location of the temporary connection?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example output-- Layer data source: C:\Users\myuser\AppData\Local\Temp\1\3c5684340c6099e99efde564bfbadb12.sde\sdedatabasename.feasturedataset\sdedatabase.featureclassname&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;for &lt;/SPAN&gt;file &lt;SPAN&gt;in &lt;/SPAN&gt;files:&lt;BR /&gt;   test = arcpy.Describe(file)&lt;BR /&gt;     &lt;SPAN&gt;if &lt;/SPAN&gt;test.layer.dataType == &lt;SPAN&gt;'FeatureLayer'&lt;/SPAN&gt;:&lt;BR /&gt;         arcpy.AddMessage(&lt;SPAN&gt;"Working on " &lt;/SPAN&gt;+ file)&lt;BR /&gt;         path = &lt;SPAN&gt;'{}\{}'&lt;/SPAN&gt;.format(inDir&lt;SPAN&gt;, &lt;/SPAN&gt;file) &lt;SPAN&gt;# Adding the inDir path to the front of the file name&lt;BR /&gt;&lt;/SPAN&gt;         desc = arcpy.Describe(path)&lt;BR /&gt;         &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;"Layer data source: {}"&lt;/SPAN&gt;.format(desc.layer.catalogPath))&lt;BR /&gt;         print ("Folder path to LYRX file: {}".format(desc.path))&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Dec 2023 15:32:23 GMT</pubDate>
    <dc:creator>mj_gis</dc:creator>
    <dc:date>2023-12-21T15:32:23Z</dc:date>
    <item>
      <title>arcpy Describe lyrx data source</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-describe-lyrx-data-source/m-p/1363617#M69463</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a relatively simple script that describes the data source and folder for lyrx files. The script worked fine in ArcMap but I am reformatting it for Pro and can't get the same output as the Arcmap script had. The script works if the lyrx is being sourced from a geodatabase or an arcgis server service. However, if the data is being sourced from an enterprise geodatabase, it gives me a temporary directory, based on whichever user is running the script. Any ideas how I can get the entire SDE path instead of the location of the temporary connection?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example output-- Layer data source: C:\Users\myuser\AppData\Local\Temp\1\3c5684340c6099e99efde564bfbadb12.sde\sdedatabasename.feasturedataset\sdedatabase.featureclassname&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;for &lt;/SPAN&gt;file &lt;SPAN&gt;in &lt;/SPAN&gt;files:&lt;BR /&gt;   test = arcpy.Describe(file)&lt;BR /&gt;     &lt;SPAN&gt;if &lt;/SPAN&gt;test.layer.dataType == &lt;SPAN&gt;'FeatureLayer'&lt;/SPAN&gt;:&lt;BR /&gt;         arcpy.AddMessage(&lt;SPAN&gt;"Working on " &lt;/SPAN&gt;+ file)&lt;BR /&gt;         path = &lt;SPAN&gt;'{}\{}'&lt;/SPAN&gt;.format(inDir&lt;SPAN&gt;, &lt;/SPAN&gt;file) &lt;SPAN&gt;# Adding the inDir path to the front of the file name&lt;BR /&gt;&lt;/SPAN&gt;         desc = arcpy.Describe(path)&lt;BR /&gt;         &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;"Layer data source: {}"&lt;/SPAN&gt;.format(desc.layer.catalogPath))&lt;BR /&gt;         print ("Folder path to LYRX file: {}".format(desc.path))&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 15:32:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-describe-lyrx-data-source/m-p/1363617#M69463</guid>
      <dc:creator>mj_gis</dc:creator>
      <dc:date>2023-12-21T15:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy Describe lyrx data source</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-describe-lyrx-data-source/m-p/1363631#M69464</link>
      <description>&lt;P&gt;Not sure what was supposed to be in those other boxes, but this worked fine for me (a little slow, though)&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os
for root, dirs, files in os.walk(r"T:\WY\HDD\RL\_layerfiles\cadastral"):
    for file in files:
        # print(file)
        if file.endswith((".lyr", ".lyrx")):
            lyrx = arcpy.mp.LayerFile(os.path.join(root,file))
            for layer in lyrx.listLayers():
                if layer.isGroupLayer:
                    continue
                if layer.isBasemapLayer:
                    continue
                print(arcpy.da.Describe(layer)["catalogPath"])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On your last line, btw, you could probably just do&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; print ("Folder path to LYRX file: {}".format(path))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 16:06:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-describe-lyrx-data-source/m-p/1363631#M69464</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-12-21T16:06:15Z</dc:date>
    </item>
  </channel>
</rss>

