I am trying to recursively go through all the directories in the "boards" directory and find files that end in '.vhd' and then output them to a text file. I am using python 3.4 so I don't have access to recursive glob.

path = '../../boards'

rel_paths = open('rel_paths.txt', 'a+')

files = [os.path.join(dirpath, f)
for dirpath, dirnames, files in os.walk(path)
    for f in files
        if f.endswith('.vhd')]

I want 'rel_paths.txt' to look like this in the inside:


1 Answers

Gurdyal On Best Solutions

if you are flexible you can use Unix command " find " instead of writing python code as follows

find ../../boards -name "*.vhd" >>  rel_paths.txt

it can be modified to suit what you need