Select to view content in your preferred language

list all data sources used in MXD or batch of MXDs in a text file

4180
5
04-13-2012 11:20 AM
MichellePearson
Deactivated User
I've been attempting to use a python script to list all data sources used in an mxd (need it for entire lists of mxd's really).  The trouble is I don't program or know python.   Is there a more direct way to do this - say a tool in ArcToolbox I don't know about? 

Here's what i've done so far.  I used the script found here: http://forums.arcgis.com/threads/20745-python-script-to-export-file-paths-of-all-features-in-mxd-int...

I created a new toolbox in ArcToolbox and added a script.  Set the source to the mxd_list.py script on my c drive.  created 2 parameters named folderPath and output (type folder and textfile).  I created a text file for the output in the same folder where my mxds are.

When I run the script it allows me to choose the folder and text file input parameters, but it crashes and I get the following message:
<type 'exceptions.IndentationError'>: expected an indented block (mxd_list.py, line 16)
Failed to execute (MXDlist).


Can anyone help me get this to work this afternoon?  I have attached the script.
Thanks,
Michelle
0 Kudos
5 Replies
DarrenWiens2
MVP Honored Contributor
Python uses indentation (at least two spaces) to delineate special blocks of code (loops [for, while], decisions [if/then/else], functions, etc.). The script you copied from the thread was posted without following Curtis Price's handy-dandy How to Post Python Code, which preserves the proper indentation needed to run the script. Take a look at that post for an example of indenting try/except blocks.
0 Kudos
CoryMacNeil1
Frequent Contributor
Hi Michelle,

To start Python works on indentation.  Your error indicates that you have a problem on Line 16, that is because the line above it is "try:" which means everything below it should be indented until you reach the error portion of the try statment, line 137 in your code.  Your "if" and "else" statements, for loops and nested "try" statements all need to be indented.

I have attached a script I wrote that will go through subfolders looking for MXD's and seeing if any layers within the MXD have broken links and print that to a text file.  It should help you with your script.

I hope this helps,
Cory
0 Kudos
MichellePearson
Deactivated User
Thank you both!  I'm using the version of the script actually included in the  "20 script tools" referenced in the message I was originally looking at instead of the one I copied from the post.  It seems to be running.  We shall see...
0 Kudos
MichellePearson
Deactivated User
The MultiMXDReport.py worked great - but left me with txt files with lots of extraneous lines.  Since I had dozens of MXDs linking to dozens of data sources, I got help on Experts-Exchange with a VBA script that extracts the data I need into an Excel table.  In case anyone here is interested - here is the link to my question on EE and an excel macro that that an EE expert kindly created for me.  
http://www.experts-exchange.com/Microsoft/Applications/Q_27675332.html#a37852862
0 Kudos
glennhazelton
Deactivated User
hi
could you paste in the txt to excel solution. the link you provided requires logging in and using a credit card.
thanks.
0 Kudos