import os list = os.listdir(dir) # dir is your directory path number_files = len(list) print number_files