EDIT
I hope this gonna work for you. Add your gdb location.
Give it a try a tell me results.
import arcpy
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r"C:\Users\user\Desktop\20181018_CHECKS\05052"
arcpy.env.addOutputsToMap = True
gdb = r"**GDBADRESS**"
fc_list = arcpy.ListFeatureClasses()
for fc in fc_list:
print (fc)
file_name = fc.split('.')[0]
arcpy.FeatureClassToGeodatabase_conversion(fc, gdb)
in_fc = [fc, fc]
arcpy.Intersect_analysis(in_fc,('{0}\{1}_inte'.format(gdb,file_name))
Tool for this: I am aware that this is code is like using a sledgehammer to crack a nut, but it was the easiest solution for me to help OP.
It is working, I don't see point of doing intersections of fls, but code is working as follows:
1) You pick feature layers from TOC
2) You select target gdb
3) Tool copies feature layer to gdb and then save intersected fls to the gdb
To use this tool save following code to the *.pyt extension and put it to the folder which you have connected in your catalog pane.
I tested it with ArcGIS Pro 2.2.3, hope it is gonna work with ArcMap.
If you need any additional help with using this, feel free to comment.
import arcpy
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "UserCustomTool"
self.alias = ""
# List of tool classes associated with this toolbox
self.tools = [Tool_for_user]
class Tool_for_user(object):
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
self.label = "Tool for user"
self.description = "By JuniorPythonNewbie for GIS stack exchange "
self.canRunInBackground = False
def getParameterInfo(self):
"""Define parameter definitions"""
# Pierwszy parametr
in_layers = arcpy.Parameter(
displayName = "Put all the layers from TOC",
name = "in_fl",
datatype = "GPFeatureLayer",
parameterType = "Required",
direction = "Input",
multiValue = True)
out_gdb = arcpy.Parameter(
displayName = "Select gdb where all stuff gonna be saved",
name = "out_gdb",
datatype = "DEWorkspace",
parameterType = "Required",
direction = "Input")
p =[in_layers, out_gdb]
return p
def isLicensed(self):
"""Set whether tool is licensed to execute."""
return True
def updateParameters(self, parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
def updateMessages(self, parameters):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
def execute(self, parameters, messages):
gdb = parameters[1].valueAsText
arcpy.env.overwriteOutput = True
chosen_fl = parameters[0].valueAsText.split(',')
for fl in chosen_fl:
arcpy.FeatureClassToGeodatabase_conversion(fl, gdb)
in_fl = [fl, fl]
arcpy.Intersect_analysis(in_fl, ('{0}\{1}_inte'.format(gdb,fl))
return