- Notifications
You must be signed in to change notification settings - Fork 638
Expand file tree
/
Copy pathP02_FileCount.py
More file actions
Latest commit
21 lines (16 loc) · 589 Bytes
/
Copy pathP02_FileCount.py
File metadata and controls
21 lines (16 loc) · 589 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Author: OMKAR PATHAK
# This script illustrates how to count number of files and directories in a diectory recursively
importos
# Path IN which we have to count files and directories
PATH='/home/omkarpathak/Documents/GITs/Python-Programs/Scripts'# Give your path here
fileCount=0
dirCount=0
forroot, dirs, filesinos.walk(PATH):
print('Looking in:',root)
fordirectoriesindirs:
dirCount+=1
forFilesinfiles:
fileCount+=1
print('Number of files',fileCount)
print('Number of Directories',dirCount)
print('Total:',(dirCount+fileCount))