Answers for "how to know number of files in a directory in linux and python"

6

python count files directory

import os
len(os.listdir(directory))
Posted by: Guest on April-03-2020
0

python monitor directory for files count

import os.path
path = os.getenv('HOME') + '/python'
num_files = len([f for f in os.listdir(path)if os.path.isfile(os.path.join(path, f))])
Posted by: Guest on November-27-2020

Code answers related to "how to know number of files in a directory in linux and python"

Python Answers by Framework

Browse Popular Code Answers by Language