<?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 Re: Use arcpy to check if .lyr file uses relative path names in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389213#M30766</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No it doesn't. I looked at my two test files in notepad (one save as layer file with mxd relative paths on, one off) and can't find the magic cookie that Grant mentioned. So I'm kind of confused.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Oct 2017 02:29:05 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2017-10-30T02:29:05Z</dc:date>
    <item>
      <title>Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389204#M30757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a library of many hundred .lyr files that are distributed to my user base along with a data package.&lt;/P&gt;&lt;P&gt;Users will save the data and layer files on various drive letters and directory locations. This works fine as the layer files are generally saved with relative file paths (creating using tool "Save To Layer File" and selecting the 'Store Relative Path' option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would now like to develop an audit process for the layer file library, and to do so I will walk through the directory structure and iterate through all of the .lyr files. For each file I will check if the data source is current (which I've worked out how to do) and then check that the .lyr file path is relative (which I haven't worked out how to do).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there an arcpy method that I can check this component of the .lyr file properties? I would imagine it sits somewhere with the layer methods, but I can't see any reference to this property in the documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 01:24:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389204#M30757</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2017-02-01T01:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389205#M30758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are methods inside the layer class&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/layer-class.htm"&gt;layer class&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 01:34:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389205#M30758</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-02-01T01:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389206#M30759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Dan.I have combed through the methods and haven't come up with anything that I think will help me, but it is entirely possible that I've missed or misinterpreted something.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My working solution for the moment is to compare the layer source (eg J: drive) with the layer location (eg C:) and if there is a difference, flag it for further investigation. I was hoping for a more definitive test if one exists though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 03:37:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389206#M30759</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2017-02-01T03:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389207#M30760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The paths can be changed... I doubt they are kept as relative since if you add a layer to a map document and separate it from its data, the link is broken... to fix, arcpy has the functionality&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Changing a layer's data source is a common requirement. There are two methods on the Layer object that help with this. The findAndReplaceWorkspacePath method is intended for replacing part or all of a layer's workspace path. The replaceDataSource method allows you to change a layer's workspace and source dataset. For a more detailed discussion, parameter information, scenarios, and code samples, please refer to the Updating and fixing data sources with arcpy.mapping help topic.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 04:03:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389207#M30760</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-02-01T04:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389208#M30761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;and an addendum, suggesting that it is way the project was saved that affects whether absolute or relative paths are saved... you will have to experiment with a project with and with out relative paths linked&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Once you've saved the layer file, you can't change the data source options from absolute to relative or vice versa. The layer will always maintain the data source option that was set for the map document at the time you saved the layer.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;From&amp;nbsp;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/map/working-with-arcmap/referencing-data-in-the-map.htm" title="http://desktop.arcgis.com/en/arcmap/latest/map/working-with-arcmap/referencing-data-in-the-map.htm"&gt;Referencing data in the map—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;at the bottom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 04:10:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389208#M30761</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-02-01T04:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389209#M30762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only way I have found to identify if a layer file is relative - is to open it in Notepad (not Notepad++. Sublime or anything else, just Notepad) and search for "&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;. . \&lt;/SPAN&gt;" - spaces and all.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Oct 2017 00:13:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389209#M30762</guid>
      <dc:creator>GrantHerbert</dc:creator>
      <dc:date>2017-10-26T00:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389210#M30763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only thing I can come up with is to copy the layerfile to another location and see if the datasource is still pointing to the same location (absolute) or not (relative):&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;main&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; shutil &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; copyfile
&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp_folder &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\GeoNet\RelativePath\tmp'&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; lyrs &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;'C:\GeoNet\RelativePath\Layerfile_relative_path.lyr'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r&lt;SPAN class="string token"&gt;'C:\GeoNet\RelativePath\Layerfile_absolute_path.lyr'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; lyr_file &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; lyrs&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\n"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; lyr_file
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr_file&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datasource_before &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dataSource
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"before:"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; datasource_before
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr_file_dest &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tmp_folder&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr_file&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; lyr_file_dest
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; copyfile&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr_file&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; lyr_file_dest&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr_tmp &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr_file_dest&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datasource_after &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; lyr_tmp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dataSource
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"after :"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; datasource_after
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; datasource_before &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; datasource_after&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;" - Datasource is Absolute path"&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;" - Datasource is Relative path"&lt;/SPAN&gt;


&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; __name__ &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'__main__'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; main&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This yields:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;C:\GeoNet\RelativePath\Layerfile_relative_path.lyr
before: C:\Fabiola\ManglaresInvemar\gdb\ManglarCentroPob.gdb\Manglares
C:\GeoNet\RelativePath\tmp\Layerfile_relative_path.lyr
after : C:\GeoNet\Fabiola\ManglaresInvemar\gdb\ManglarCentroPob.gdb\Manglares
 - Datasource is Relative path

C:\GeoNet\RelativePath\Layerfile_absolute_path.lyr
before: C:\Fabiola\ManglaresInvemar\gdb\ManglarCentroPob.gdb\Manglares
C:\GeoNet\RelativePath\tmp\Layerfile_absolute_path.lyr
after : C:\Fabiola\ManglaresInvemar\gdb\ManglarCentroPob.gdb\Manglares
 - Datasource is Absolute path‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:51:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389210#M30763</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T17:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389211#M30764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;The only way I have found to identify if a layer file is relative - is to open it in Notepad (not Notepad++. Sublime or anything else, just Notepad) and search for "&lt;/SPAN&gt;&lt;SPAN style="background-color: #ffffff; border: 0px;"&gt;. . \&lt;/SPAN&gt;&lt;SPAN style="background-color: #ffffff;"&gt;" - spaces and all.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;If this works consistently, you could easily read the layer file with Python and look for this string. It's a kluge, but why not if it works?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;lyr_relpath&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyrfile&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; open&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyrfile&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'rb'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; f&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;read&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gotRelative &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;data&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;find&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;". . \\"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;or&lt;/SPAN&gt; 
&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;&amp;nbsp;&amp;nbsp; data&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;find&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;". . /"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;‍‍‍‍‍‍‍‍&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; gotRelative‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:51:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389211#M30764</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T17:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389212#M30765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/people/curtvprice"&gt;curtvprice&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this code work for you? I just applied it to the two layerfiles I have and both returned false.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Oct 2017 17:56:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389212#M30765</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2017-10-29T17:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389213#M30766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No it doesn't. I looked at my two test files in notepad (one save as layer file with mxd relative paths on, one off) and can't find the magic cookie that Grant mentioned. So I'm kind of confused.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Oct 2017 02:29:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389213#M30766</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2017-10-30T02:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389214#M30767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you see a drive path when you open them in&amp;nbsp; Notepad?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Nov 2017 19:32:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389214#M30767</guid>
      <dc:creator>GrantHerbert</dc:creator>
      <dc:date>2017-11-03T19:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389215#M30768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Nov 2017 19:44:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389215#M30768</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2017-11-03T19:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389216#M30769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't either, Xander's method is probably best then.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Nov 2017 21:47:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389216#M30769</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2017-11-03T21:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Use arcpy to check if .lyr file uses relative path names</title>
      <link>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389217#M30770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is what I see when I open the layer file in Notepad, for a layer file created with arcpy.SaveToLayerFile_management with is_relative_path set to "RELATIVE".&amp;nbsp;&lt;IMG alt="Layer File Relative Path in Notepad" class="image-1 jive-image j-img-original" src="/legacyfs/online/382598_Checking Relative Path in Layer File with Notepad.JPG" style="width: 620px; height: 339px;" /&gt;&lt;/P&gt;&lt;P&gt;However I have just realized that the ". . \"&amp;nbsp;does not always exist - it depends on where your data&amp;nbsp;resides. However, a check for ": \" may identify an absolute path. This will probably require searching for the encoded values, which will look like b'\x00F' for example. I have no idea what the correct code for ':' would be though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Nov 2017 23:48:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-arcpy-to-check-if-lyr-file-uses-relative-path/m-p/389217#M30770</guid>
      <dc:creator>GrantHerbert</dc:creator>
      <dc:date>2017-11-03T23:48:43Z</dc:date>
    </item>
  </channel>
</rss>

