<?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: Export to PDF and Save a Copy saves to the wrong folder in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/export-to-pdf-and-save-a-copy-saves-to-the-wrong/m-p/502788#M39498</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Matthew and Xander. &lt;/P&gt;&lt;P&gt;Using the os.path.join worked like a charm.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Jul 2015 22:42:31 GMT</pubDate>
    <dc:creator>AndrewKlimek</dc:creator>
    <dc:date>2015-07-06T22:42:31Z</dc:date>
    <item>
      <title>Export to PDF and Save a Copy saves to the wrong folder</title>
      <link>https://community.esri.com/t5/python-questions/export-to-pdf-and-save-a-copy-saves-to-the-wrong/m-p/502783#M39493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am using parameters to save an mxd and export a pdf.&amp;nbsp; Tried using both workspace and folder.&amp;nbsp; Problem is that it gets saved to one folder down from the one I tell it two.&amp;nbsp; It also adds the name of the folder I tell I wanted it in at the front of the mxd and pdf.&amp;nbsp; What am I doing wrong.&amp;nbsp; This is my very first script!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# 8/16/2011&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Aerial Map Script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# import arcpy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy.mapping&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Define Map Document location.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("C:/GIS/Script1/maps/Template_Aerial_Imagery4.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Define Data Frame.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Add a Parameter for Locating the Layer you want to Add and Add the Layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;addLayer = arcpy.mapping.Layer(Layer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mapping.AddLayer(df,addLayer,"TOP")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Select Layer, Zoom to Layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management(addLayer,"NEW_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.zoomToSelectedFeatures()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Define scale of dataframe and set the reference scale.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.scale = 2400&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df.referenceScale = 2400&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Clear the Selection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management(addLayer,"CLEAR_SELECTION")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Change "Project Name (PN)" &amp;amp; "County, State (CS)" Text; Using Parameters&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ALPname = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elPN = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","Project Name")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elPN.text = ALPname&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CSname = arcpy.GetParameterAsText(2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elCS = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","County, State")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;elCS.text = CSname&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Refresh the Active View&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshActiveView&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# save mxd&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ProjNum = arcpy.GetParameterAsText(3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.saveACopy(arcpy.GetParameterAsText(4) + ProjNum + "_Aerial_Imagery.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Export to PDF&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PDFloc = arcpy.GetParameterAsText(5)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mapping.ExportToPDF(mxd,PDFloc + ProjNum + "_Aerial_Imagery.pdf")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Clear the mxd from script lock&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;_____________________________________________________________________________&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also I tried to trouble shoot the problem by exporting a random map in ArcMap using python command line and it althought the name of the file was correct it also saved it a folder down one in the list.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; import arcpy.mapping&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; arcpy.env.workspace = "C:\GIS\test\New_Folder"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; arcpy.mapping.ExportToPDF(mxd,"output.pdf")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It will export it to the test folder instead of the New_Folder folder.&amp;nbsp; ???&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Aug 2011 18:23:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-to-pdf-and-save-a-copy-saves-to-the-wrong/m-p/502783#M39493</guid>
      <dc:creator>deleted-user-MS0lE1F_0-sy</dc:creator>
      <dc:date>2011-08-24T18:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: Export to PDF and Save a Copy saves to the wrong folder</title>
      <link>https://community.esri.com/t5/python-questions/export-to-pdf-and-save-a-copy-saves-to-the-wrong/m-p/502784#M39494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I got it figured out. In case someone else runs into this....I needed to put a "/" after the GetParameter.&amp;nbsp; I thought I had tried that, so simple.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Aug 2011 22:50:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-to-pdf-and-save-a-copy-saves-to-the-wrong/m-p/502784#M39494</guid>
      <dc:creator>deleted-user-MS0lE1F_0-sy</dc:creator>
      <dc:date>2011-08-24T22:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Export to PDF and Save a Copy saves to the wrong folder</title>
      <link>https://community.esri.com/t5/python-questions/export-to-pdf-and-save-a-copy-saves-to-the-wrong/m-p/502785#M39495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm having the same issue with my output file (a txt file in my case) getting outputted to the wrong folder in the directory path.&amp;nbsp; I have tried to follow Matthew's solution above to incorporate the "/" after the GetParameter, but I end up with syntax errors.&amp;nbsp; Could someone alter his code to show me where the "/" should be placed?&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2015 19:00:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-to-pdf-and-save-a-copy-saves-to-the-wrong/m-p/502785#M39495</guid>
      <dc:creator>AndrewKlimek</dc:creator>
      <dc:date>2015-07-02T19:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Export to PDF and Save a Copy saves to the wrong folder</title>
      <link>https://community.esri.com/t5/python-questions/export-to-pdf-and-save-a-copy-saves-to-the-wrong/m-p/502786#M39496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without seeing the code and error it's hard to say.&amp;nbsp; Are you putting "/" for the rest of the path? If you use "\" you need to add the r at the beginning of the path."Y:/folder1/folder2/folder3/PARAMETER INPUT"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or&amp;nbsp;&amp;nbsp;&amp;nbsp; r"Y:\folder1\folder2\folder3\PARAMETER INPUT" .&amp;nbsp;&amp;nbsp; Is your output setting of the parameter a text?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2015 19:20:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-to-pdf-and-save-a-copy-saves-to-the-wrong/m-p/502786#M39496</guid>
      <dc:creator>deleted-user-MS0lE1F_0-sy</dc:creator>
      <dc:date>2015-07-02T19:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Export to PDF and Save a Copy saves to the wrong folder</title>
      <link>https://community.esri.com/t5/python-questions/export-to-pdf-and-save-a-copy-saves-to-the-wrong/m-p/502787#M39497</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It would be better to use the os.path.join to create the path to the output file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
my_folder = r"C:\aFolder\aSubFolder"
my_filename = "someFileName.ext"
print os.path.join(my_folder, my_filename)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... will yield this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;C:\aFolder\aSubFolder\someFileName.ext&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And you can even do this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os
my_folder = r"C:\aFolder\aSubFolder"
my_filename = "someFileName.ext"
print os.path.join(my_folder, "anotherSubFolder", my_filename)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... which will yield this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;C:\aFolder\aSubFolder\anotherSubFolder\someFileName.ext&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:04:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-to-pdf-and-save-a-copy-saves-to-the-wrong/m-p/502787#M39497</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T22:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: Export to PDF and Save a Copy saves to the wrong folder</title>
      <link>https://community.esri.com/t5/python-questions/export-to-pdf-and-save-a-copy-saves-to-the-wrong/m-p/502788#M39498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Matthew and Xander. &lt;/P&gt;&lt;P&gt;Using the os.path.join worked like a charm.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2015 22:42:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-to-pdf-and-save-a-copy-saves-to-the-wrong/m-p/502788#M39498</guid>
      <dc:creator>AndrewKlimek</dc:creator>
      <dc:date>2015-07-06T22:42:31Z</dc:date>
    </item>
  </channel>
</rss>

