A simple Python CLI tool that scans a directory, lists its files, counts file types, and displays file-type statistics sorted by frequency.
- Scan a user-specified directory
- Validate that the path exists
- Validate that the path is a directory
- List files with numbered output
- Count total files
- Detect file extensions
- Handle files without extensions
- Count files by type
- Sort file types by frequency
Enter a folder path: /home/saeed/Documents
Please wait for scanning directory: /home/saeed/Documents
1. report.pdf
2. photo.jpg
3. data.csv
4. README
5. script.py
6. another.jpg
Total files: 6
File types:
1. .jpg = 2
2. .pdf = 1
3. .csv = 1
4. No extension = 1
5. .py = 1
- Python
- pathlib
- dictionaries
- loops and conditionals
- sorted()
- lambda
- enumerate()
This project was built as a practical Python exercise to practice working with files and directories.
Through this project I practiced:
- Python modules and imports
pathlib.Path- File and directory handling
- Dictionary-based counting
- Iteration with
for enumerate()- Sorting with
sorted() - Using
lambdawithkey= - Basic input validation
- Writing readable Python code
Make sure Python is installed, then run:
python3 main.pyEnter the path of the directory you want to scan.
Completed ✅
This is a small learning project and will be kept intentionally simple. More advanced features may be added in future projects as I improve my Python skills.