👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
I am working on a script to recursively go through subfolders in a mainfolder and build a list off a certain file type. I am having an issue with the script. Its currently set as follows
for root, subFolder, files in os.walk(PATH):
for item in files:
if item.endswith(".txt") :
fileNamePath = str(os.path.join(root,subFolder,item))
the problem is that the subFolder variable is pulling in a list of subfolders rather than the folder that the ITEM file is located. I was thinking of running a for loop for the subfolder before and join the first part of the path but I figured Id double check to see if anyone has any suggestions before that. Thanks for your help!
👻 Read also: what is the best laptop for engineering students?
We hope this article has helped you to resolve the problem. Apart from Recursive sub folder search and return files in a list python, check other __main__ Python module-related topics.
Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.
By the way, this material is also available in other languages:
- Italiano Recursive sub folder search and return files in a list python
- Deutsch Recursive sub folder search and return files in a list python
- Français Recursive sub folder search and return files in a list python
- Español Recursive sub folder search and return files in a list python
- Türk Recursive sub folder search and return files in a list python
- Русский Recursive sub folder search and return files in a list python
- Português Recursive sub folder search and return files in a list python
- Polski Recursive sub folder search and return files in a list python
- Nederlandse Recursive sub folder search and return files in a list python
- 中文 Recursive sub folder search and return files in a list python
- 한국어 Recursive sub folder search and return files in a list python
- 日本語 Recursive sub folder search and return files in a list python
- हिन्दी Recursive sub folder search and return files in a list python
Singapore | 2023-03-29
Maybe there are another answers? What Recursive sub folder search and return files in a list python exactly means?. I just hope that will not emerge anymore
Tallinn | 2023-03-29
I was preparing for my coding interview, thanks for clarifying this - Recursive sub folder search and return files in a list python in Python is not the simplest one. I am just not quite sure it is the best method
Shanghai | 2023-03-29
Thanks for explaining! I was stuck with Recursive sub folder search and return files in a list python for some hours, finally got it done 🤗. Checked yesterday, it works!