I want to do an os.path.join that contains a list in filenames
because there are 3 files in that final folder. I want to only use the PST.shp
import os
fo = []
f = r'C:\Users\user\Desktop\folder\folder1'
for dirpath,dirnames,filenames in os.walk(f):
print(filenames)
#fo.append(os.path.join(dirpath,filenames))
gives:
[]
[]
['PST.dbf', 'PST.shp', 'PST.shx']
[]
['PST.dbf', 'PST.shp', 'PST.shx']
[]
['PST.dbf', 'PST.shp', 'PST.shx']
[]
['PST.dbf', 'PST.shp', 'PST.shx']
[]
How to filter so I use only the PST.shp
full path in the list fo
?
something like:
fo = []
f = r'C:\Users\user\Desktop\folder\folder1'
for dirpath,dirnames,filenames in os.walk(f):
if filenames not empty:
print(filenames)
fo.append(os.path.join(dirpath,filenames[0][1]))