Skip to content

Commit 4384945

Browse files
authored
Merge pull request #334 from anut123/main
Changes done
2 parents 2b0a510 + c398331 commit 4384945

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
3+
#path where we have to count files and directories
4+
path = input("Enter path: ")
5+
6+
noOfFiles = 0
7+
noOfDir = 0
8+
9+
for base, dirs, files in os.walk(path):
10+
print('Looking in : ',base)
11+
for directories in dirs:
12+
noOfDir += 1
13+
for Files in files:
14+
noOfFiles += 1
15+
#print number of files,directories,total
16+
print('Number of files',noOfFiles)
17+
print('Number of Directories',noOfDir)
18+
print('Total:',(noOfDir + noOfFiles))
23.5 KB
Loading
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To count number of files and sub directories in a directory
2+
3+
## How to Run?
4+
5+
* Create folder in your desktop
6+
* Enter the path of your Folder
7+
* Run 'Count_number_of_files.py'
8+
9+
## Output
10+
11+
![Output](Output.JPG)

0 commit comments

Comments
 (0)