Skip to content

Commit 8370aac

Browse files
authored
Merge pull request #359 from Sapna2001/diskSpace
free disk space in python
2 parents f974de2 + ff7833c commit 8370aac

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Python/Free_Disk_Space/Readme.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Free Disk Space
2+
Script to find free disk space present in the given path.
3+
4+
## How to use this script?
5+
6+
Just type the following in your command prompt:
7+
8+
python script.py
9+
10+
## Screenshot
11+
![demo](https://user-images.githubusercontent.com/56690856/99070578-8173a180-25d6-11eb-8eec-526624f80866.png)

Python/Free_Disk_Space/script.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import shutil
2+
3+
# Path
4+
path = input("Enter the path:")
5+
6+
# Get the disk usage statistics
7+
# about the given path
8+
stat = shutil.disk_usage(path)
9+
10+
# Print free space in the disk
11+
# shutil.disk_usage(path) returns a tuple with the attributes total, used and free in bytes, therefore the free disk space can be found in the index 2
12+
print("Free disk space present in the given path:"+str(stat[2])+" bytes")
13+

0 commit comments

Comments
 (0)