Question: I know there are several posts that touch on this, but I haven't found one that works for me yet. I need to create a list of files with an .mxd extension by searching an entire mapped directory. I used this code and it works:

```
    import os
    file_list = []
    for (paths, dirs, files) in os.walk(folder):
        for file in files:
            if file.endswith(".mxd"):
                file_list.append(os.path.join(paths, file))

```

However, it only works on the C drive. I need to be able to search for these files on a mapped drive of my choosing. Here's the script I'm using, but it doesn't work. I know there is an mxd file in the subdirectory of this drive, but it isn't being reported in the file list. In fact, the file list is totally empty, and it shouldn't be.

```
    import os
    path = r"U:/TEST/"
    filenamelist = []
    for files in os.walk(path):
         if file.endswith(".mxd"):
            filenamelist.append(files)

```

Does someone see anything wrong in my second block of code that would provent it from iterated through subdirectories at the given path and reporting back files with an .mxd extension?

Answer: 
[os.walk(path)](http://docs.python.org/2/library/os.html#os.walk) yields a 3-tuple which is commonly unpacked as `root, dirs, files`. So instead of 

```
for files in os.walk(path):
    ...

```

use

```
for root, dirs, files in os.walk(path):
    for filename in files:
        if filename.endswith(".mxd"):
            filenamelist.append(filename)

```
Here's the final script that worked for crawling on a drive root other than C:

```
import os
file_list = []
path = r'U:\\'
for (dirpath, subdirs, files) in os.walk(path):
    for file in files:
        if file.endswith(".mxd"):
            file_list.append(os.path.join(dirpath, file))

```