Hey guys.
I have a shapefile in a folder on my desktop and I'm afraid of deleting it.
Is there any way to know in which ArcGis project we are using a particular shapefile?
Thank you all.
You might consider creating an archive file geodatabase and convert it to a feature class. Add some metadata about where it was originally stored so that you can restore it later if necessary. If you already have multiple copies elsewhere just ignore what I wrote.
Hi @MarcBordelon!
I know this is the most obvious, safest and probably the only solution.
My question was to know if anyone knows of another procedure that might have the same result.
The best thing is to have everything well organized, which I didn't have.
Thanks for your tip.
Thanks for your help, @BobBooth1 👍
Something like this should work:
import arcpy import os def find_files(folder_path, file_extension): file_list = [] for root, dirs, files in os.walk(folder_path): for file in files: if file.endswith(file_extension): file_list.append(os.path.join(root, file)) return file_list # Example usage folder_path = 'C:\\Users\\my_user_name\\Documents\\ArcGIS\\Projects\\' file_extension = '.aprx' found_projects = find_files(folder_path, file_extension) #print(found_projects) for a_project in found_projects: aprx = arcpy.mp.ArcGISProject(a_project) the_maps = aprx.listMaps() for a_map in the_maps: layers = a_map.listLayers() for layer in layers: try: print(layer.dataSource) # Check if he shapefile is used in this layer if layer.dataSource == 'your_path_to_shapefile': print("The data source is here!") except: print("problem, dataSource may not be supported")
I'm all for a Python solution.
There are some sample snippets in this help topic:
https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/updatingandfixingdatasources.htm
There is an old sample for inventorying a folder of ArcMap (.mxd) maps and reporting their data sources, but it would need to adapted to work with ArcGIS Pro projects. You could borrow the document iteration and CSV report writing logic from there.
https://www.arcgis.com/home/item.html?id=18c19ec00acb4d568c27bc20a72bfdc8
Another approach would be to zip up that folder (or move it to an archive drive) and keep it around for a while. If you find you need it, put it where it makes sense and fix the layer.
Thanks @jcarlson. I'll follow your tip.
There might be a way in ArcPy to loop through a series of projects and print off any data sources that are looking for a ".shp", but that's a bit outside of my expertise. I think you'll want the arcpy.mp module:
https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layer-class.htm
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.