I want to loop many mxds within a folder to retrieve layer,connection,etc. information using python.
I just need the syntax for looping through the mxds.
You can use the Walk function in python that Michael had mentioned to loop throught the mxds. For each mxd, you can use what he later suggested with looping through the dataframes and layers.
A loop within a loop.
Rebecca Strauch, GISP produced this Python addin for data inventory and “broken-link” repair.
which does project inventory, if it doesn't serve purposes, perhaps she might have some commentary on what you are trying to accomplish
Devin, it definitly is worth trying my data inventory addin, as Dan mentioned. since there are so many different types of data and data connections that can be within any mxd, there are many tests that need to be filtered thru to find the right pe. The add in does that fairly well, but still may not catch ALL oes yet. But it does spit out an excel and .csv output so you can see what you have. It will do recursive mxds in a folder, and runs fairly fast so, the inventory part you should try.
if it doesn't get what you need, and .addin is just a zip file....change the extension and unzip. You'll see how I looped thru everything, and you can grab snippets from thatand modify if needed.
This looks great, I just browsed it quickly. Good advice use on a non-working testing folder/files. I will test this out. Thank you.
Keep in mind, if I remember correctly, the inventory lists all whether broken link or not.
The broken link list will list only those, and may differ depending on relative relationship, and user permissions, if you copy the data.....which I still recommend for testing. I'm using it to find where users have local data for mxd's that are shared and in a network drive. helps me find the local data that needs to be centrally located and fixed. That might not be your need....but just a tidbit of possible usage.
Interesting, I used Select folder to walk thru & List all types of feature classes. It writes to excel with just title headings.
Are you saying all three output files end up blank? I just downloaded and ran it (second button...first only shows databases, not mxd data) against a folder that I created in the last few days (i.e., not the computer or folder I created and tested the addin on originally) I had two mxd it, and all three files were populated. For example, the .txt file showed...
Maybe the excel file is a different version? Maybe try double clicking the .csv and have it open in your versions of excel?
Yes, all outputs were blank. I opened the csv and it is blank also.
You may want to change the .addin file to .zip, expand it and try running thru the toolbox instead as an addin with the buttons. That way you can see a bit more of what it is trying to do. Not sure why it is coming out blank, unless it is one of the types I dont have come red yet. I think I have a lot of notes in the .py script itself on what does and doesn't work.
I went ahead and did as you suggested. I opened and parsed the syntax to attempt in getting only what I need. No luck in successfully creating a script for what I want. I apologize for taking up your time. You have been more than helpful. I don't know what I cant seem to get this right to loop all mxds.