Answers for "get number of files in directory python"

6

python count files directory

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

get directory of file python

import os 
dir_path = os.path.dirname(os.path.realpath(__file__))
Posted by: Guest on April-03-2020
12

get files in directory python

import os
files_and_directories = os.listdir("path/to/directory")
Posted by: Guest on June-12-2020
-1

count a number of file in a folder python

import os
len([item for item in os.listdir(folderPath)])
Posted by: Guest on April-17-2021
0

How to count the number of files in a directory using Python

import os, os.path

# simple version for working with CWD
print len([name for name in os.listdir('.') if os.path.isfile(name)])

# path joining version for other paths
DIR = '/tmp'
print len([name for name in os.listdir(DIR) if os.path.isfile(os.path.join(DIR, name))])
Posted by: Guest on September-05-2021

Code answers related to "get number of files in directory python"

Python Answers by Framework

Browse Popular Code Answers by Language