Home

Published

- 1 min read

python get all file names in a dir

img of python get all file names in a dir

The solution for this is noted below

python get all file names in a dir

Solution

   from os import listdir
from os.path import isfile, join
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]

Try other methods by searching on the site. That is if this doesn’t work