I thought I had this working before with your help but I was mistaken. I have continued to tweak and here is where I am. When I run it in VB I get the error: "EOL while scanning string literal"
In all the forums and documents I see I can't seem to find a shapefile to a completely new location/GBD. I wonder if I need to break this change up so that maybe I change name (to new GBD file name) then change source - IDK. Here is the code:
import arcpy
from arcpy import env
# Set the workspace for the folder containing MXDs
arcpy.env.workspace = r"C:\Test2"
mxdList = arcpy.ListFiles("*.mxd")
# Iterate through all MXDs in the workspace
for mxd in mxdList:
mxdpath = env.workspace + "\\" + mxd
print (mxd + "Is being processed")
mxdNext = arcpy.mapping.MapDocument(mxdpath)
for lyr in arcpy.mapping.ListLayers(mxdNext, "old_shapefile", df):
if lyr.supports("DATASOURCE"):
if lyr.dataSource == r"C:\Test\Old_Shapefile.shp":
lyr.replaceDataSource(r"C:\Test\Old_Shapefile.shp", "SHAPEFILE_WORKSPACE",
r"C:\Production_Data\Test\Final Data.gbd","FILEGDB_WORKSPACE", "New_Name")
lyr.name == "New_Name":
print("lyr.name")
mxdNext.save()
arcpy.RefreshTOC()
del mxd