# Change Feature Classes to Relative Path Lyr files
import arcpy, csv, os
from arcpy import env
env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
messageStr = str(mxd)
arcpy.AddMessage(messageStr)
arcpy.env.workspace = "C:\\GeneralWorkData\\ArcGIS Test Data\\Test Data From,to Martin B\\Relative_Paths_Lyr_Files"
for fc in arcpy.mapping.ListLayers(mxd):
fc = str(fc)
out_layer = fc + ".lyr"
arcpy.SaveToLayerFile_management(fc,out_layer,"RELATIVE")
messageStr = out_layer
arcpy.AddMessage(messageStr)
This loops round all the layer names in the currently loaded data. Works fine until it hits layer called "Observed pipeline/cable", and gives the following message:ERROR 000732: Input Layer: Dataset Observed pipeline/cable does not exist or is not supported". Failed to execute (SaveToLayerFile)."Is it thinking the forward slash is part of a directory(which it isn't)? What do I do to make SaveToLayerFile() accept the forward slash as part of the layer name?