I am running a script from the Python window in ArcMap.
listOfLayers = arcpy.mapping.ListLayers(mxd, "", df)
fileGeodb = r"C:\foo\bar\gdb_name.gdb"
for layer in listOfLayers:
arcpy.FeatureClassToFeatureClass_conversion(layer, fileGeodb, layer.name)
This exports each layer to the geodatabase, but also adds it to the mxd. How can I avoid adding it to the mxd?
ETA I've read the documentation here but adding to the mxd (or not) is not one of the options in the parameters. http://pro.arcgis.com/en/pro-app/tool-reference/conversion/feature-class-to-feature-class.htm
If you're using ArcMap, you can uncheck this option in the Geoprocessing Options: Geprocessing menu > Geoprocessing Options > Uncheck "Add results of geoprocessing operations to the display".
You can also use the env.addOutputsToMap property:
arcpy.env.addOutputsToMap = 0
listOfLayers = arcpy.mapping.ListLayers(mxd, "", df)
fileGeodb = r"C:\foo\bar\gdb_name.gdb"
for layer in listOfLayers:
arcpy.FeatureClassToFeatureClass_conversion(layer, fileGeodb, layer.name)