I am trying to write a function that returns the path of the first file found in a nest of folders. What I have so far is :
def dicom_name(rootDir):
for dirName, subdirList, fileList in os.walk(rootDir):
for f in fileList:
print(dirName,f)
return(os.path.join(dirName,f))
break
Right now if I run this and then run
dcm=dicom_name("test_dir")
print(dcm)
I see "None"
I have tried different placements of the return and break statements. What is the correct way to do what I'm trying to do?