Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python count files directory

import os
len(os.listdir(directory))
Comment

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))])
Comment

PREVIOUS NEXT
Code Example
Python :: error tokenizing data. c error 
Python :: python order dataframe according to date time 
Python :: pygame scale image python 
Python :: legend size matplotlib 
Python :: dataframe to csv without ids 
Python :: get hour python 
Python :: conda install lxml 
Python :: get gpu device name tensorflow 
Python :: get ip from instance id boto3 
Python :: install fastapi conda 
Python :: use nltk to remove stop words 
Python :: python print traceback from exception 
Python :: how to convert data type of a column in pandas 
Python :: installing pip 
Python :: sqlalchemy query bilter by current month 
Python :: python format seconds to hh mm ss 
Python :: change tkinter window name 
Python :: split data validation 
Python :: request url in web scraping 
Python :: save an image in python as grayscale cv2 
Python :: hibernate windows with python 
Python :: python everything after last slash 
Python :: not x axis labels python 
Python :: python how to write pandas dataframe as tsv file 
Python :: pyspark date to week number 
Python :: module not found not module name channels in python 
Python :: python cv2 read image grayscale 
Python :: install python on ubuntu 
Python :: dj_database_url 
Python :: create a directory python 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =