Delete Files in a folder and disregard an existing folder

المشرف العام

Administrator
طاقم الإدارة
I did a lot of geoprocessing steps and now I like to delete all files including result, result, _join, _interand reclass in their name. I can do this with the following

import glob import os for fl in glob.glob(r"D:\Users\julia\erste_aufg\delete\*result*" ): os.remove(fl) for f2 in glob.glob(r"D:\Users\julia\erste_aufg\delete\*result*" ): os.remove(f2) for f3 in glob.glob(r"D:\Users\julia\erste_aufg\delete\*_join*" ): os.remove(f3) for f4 in glob.glob(r"D:\Users\julia\erste_aufg\delete\*_inter*" ): os.remove(f4) for f5 in glob.glob(r"D:\Users\julia\erste_aufg\delete\*reclass*" ): os.remove(f5) see here.

But before deleting I created a resultfolder in the folder(workspace) with the files and copied the results of the geoprocessing steps which I need furthermore to this resultfolder. Because of this resultfolder the code to delete is not working any more. What can I do that the delete-code disregards the resultfolder?

(The code down is just to make the question more clear)

import arcpy import os from arcpy import env env.workspace = r"env.workspace = r"D:\Users\julia\urban_A_sel"" #new folder # Set local variables out_folder_path = env.workspace out_name = "resultfolder" # Execute CreateFolder arcpy.CreateFolder_management(out_folder_path, out_name) newpath= env.workspace + "\\" + out_name out_gdb_path = newpath arcpy.CreateFileGDB_management(out_gdb_path, "output.gdb") outWorkspace= newpath +"\\"+"output.gdb" resultList = arcpy.ListFeatureClasses("*_result*") arcpy.FeatureClassToGeodatabase_conversion(resultList, outWorkspace)

أكثر...
 
أعلى