Chrome Extension

List all files of a directory using os Python

from os import listdir
from os.path import isfile, join

dirPath = "path/to/my/directory"
allFileAndFolders = listdir(dirPath)

allFiles = [f for f in allFileAndFolders if isfile(join(dirPath, f))]
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

You can use the os.listdir() method to list all files and folders inside a directory. You need to pass the directory path to this method and it will return you everything inside the directory.

Search Index Data (The code snippet can also be found with below search text)

os.listdir python
Was this helpful?
0 Comments
Join Devsheet Ask a Question