Export to PDF and Save a Copy saves to the wrong folder

Discussion created by mbd7878 on Aug 24, 2011
Latest reply on Jul 6, 2015 by aklimek
I am using parameters to save an mxd and export a pdf.  Tried using both workspace and folder.  Problem is that it gets saved to one folder down from the one I tell it two.  It also adds the name of the folder I tell I wanted it in at the front of the mxd and pdf.  What am I doing wrong.  This is my very first script!

# 8/16/2011
# Aerial Map Script

# import arcpy.
import arcpy.mapping

# Define Map Document location.
mxd = arcpy.mapping.MapDocument("C:/GIS/Script1/maps/Template_Aerial_Imagery4.mxd")

# Define Data Frame.
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]

# Add a Parameter for Locating the Layer you want to Add and Add the Layer
Layer = arcpy.GetParameterAsText(0)
addLayer = arcpy.mapping.Layer(Layer)

# Select Layer, Zoom to Layer.

# Define scale of dataframe and set the reference scale.
df.scale = 2400
df.referenceScale = 2400

# Clear the Selection

# Change "Project Name (PN)" & "County, State (CS)" Text; Using Parameters
ALPname = arcpy.GetParameterAsText(1)
elPN = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","Project Name")[0]
elPN.text = ALPname
CSname = arcpy.GetParameterAsText(2)
elCS = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT","County, State")[0]
elCS.text = CSname

# Refresh the Active View

# save mxd
ProjNum = arcpy.GetParameterAsText(3)
mxd.saveACopy(arcpy.GetParameterAsText(4) + ProjNum + "_Aerial_Imagery.mxd")

# Export to PDF
PDFloc = arcpy.GetParameterAsText(5)
arcpy.mapping.ExportToPDF(mxd,PDFloc + ProjNum + "_Aerial_Imagery.pdf")

# Clear the mxd from script lock
del mxd


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.

>>> import arcpy
>>> import arcpy.mapping
>>> mxd = arcpy.mapping.MapDocument("CURRENT")
>>> arcpy.env.workspace = "C:\GIS\test\New_Folder"
>>> arcpy.mapping.ExportToPDF(mxd,"output.pdf")

It will export it to the test folder instead of the New_Folder folder.  ???