Skip to content
Advertisement

How do I output a recursive list of files to a text file without using glob (python3.4)

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.

JavaScript

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

../../boards/foo/bar/file_name1.vhd
../../boards/foo/bars/file_name2.vhd

Advertisement

Answer

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

JavaScript

it can be modified to suit what you need

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement