I try to convert with arcpy (python 2.7.8) 50 KML and KMZ files, that i downloaded from google earth into shapefiles. All files located in many sub-Folders. All Sub Folders are located in one large directory. When i run this code:

import arcpy,fnmatch,os

rootPath = r"C:\Project\gis\layers"
pattern = '*.km*'

for root, dirs, files in os.walk(rootPath):
    for filename in fnmatch.filter(files, pattern):
        print(os.path.join(root, filename))
        arcpy.KMLToLayer_conversion( r"C:\Project\gis\layers" ,r'C:\Project\gis') 

i get an error:

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000814: Invalid file type
Failed to execute (KMLToLayer).

I red:

Python Script to convert a mass of KMLs to a single fGDB

http://resources.arcgis.com/en/help/main/10.2/index.html#/KML_To_Layer/00120000004w000000/ but didn't understand my code mistake

1 Answer 1


I think you are seeing that particular error message from this line of your code:

arcpy.KMLToLayer_conversion( r"C:\Project\gis\layers" ,r'C:\Project\gis')

arcpy.KMLToLayer_conversion expects a file as its first parameter (KML or KMZ) but you are giving it a folder name.

You could try concatenating the contents of your filename variable, with the appropriate delimiter, onto it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.