A Python-based utility for exploring directories, filtering files, and generating reports. This tool combines user-friendliness with advanced features, making it suitable for beginners and power users alike.
- Search by File Extension: Look for single or multiple file types.
- Interactive Mode: Allows users to input folder paths and file extensions dynamically.
- Progress Feedback: Displays a progress bar using
tqdm
during directory traversal. - Error Handling: Handles invalid inputs and inaccessible directories gracefully.
- Formatted Results: Presents file counts in a clean, tabular format.
- Detailed Logging: Logs activities and errors for auditing and debugging.
- Flexible Filters:
- File size range (e.g., min/max size).
- Modification date range.
- Writable or executable file filters.
- Keyword search within file contents.
- Comprehensive Reporting:
- Export results to CSV, JSON, or Excel.
- Compress reports into ZIP files for easy sharing.
- Enter the folder path to explore.
- Provide one or more file extensions to search for (e.g.,
py, txt, csv
). - Optionally specify filters like name patterns, size limits, or date ranges.
- The script scans the specified folder and its subdirectories.
- Counts files that match the provided filters and extensions.
- Displays results in a table with relative directory paths, file counts, and sizes.
- Generates detailed reports for further analysis.
- Python 3.x
- Libraries: Install dependencies using:
pip install pandas tqdm openpyxl
- Save the script as
Explorer.py
. - Open a terminal or command prompt.
- Run the script with:
python Explorer.py
- Follow the on-screen prompts for interactive mode, or customize the
main
function for predefined inputs.
Enter the folder path to explore: /path/to/directory
Enter the file extensions to search for (comma-separated): py, txt
Directory | Count
------------------------------------------------------------
/path/to/directory | 3
/path/to/directory/subdir1 | 5
/path/to/directory/subdir2 | 2
from datetime import datetime
results = explore(
extension=None,
folder_path="/path/to/folder",
multiple_extensions=[".py", ".txt"],
name_pattern="*example*",
start_date=datetime(2023, 1, 1),
end_date=datetime(2023, 12, 31),
min_size=1024, # Minimum 1KB
max_size=1048576, # Maximum 1MB
depth=2,
writable=False,
executable=False
)
# Generate reports
generate_report(results, report_file="report.csv", format="csv")
compress_report("report.csv", "report.zip")
explore(extension, folder_path, ...)
: Traverses directories and filters files based on criteria.generate_report(data, report_file, format)
: Creates reports in CSV, JSON, or Excel formats.compress_report(report_file, zip_file)
: Compresses report files into ZIP format.log_activity(action, details)
: Logs actions and errors to a JSON file.
- Handles user inputs and calls the necessary functions.
- Provides error handling and feedback during execution.
- Save results to additional formats like YAML or plain text.
- Extend filters to include file owners or permissions.
- Enhance reporting to include visual charts or graphs.
- Unit tests are included to validate core functionality:
python -m unittest Explorer.py
This project is licensed under the MIT License. Feel free to use, modify, and distribute this tool as per the license terms.
Contributions and feedback are welcome! Submit issues or pull requests to help improve this tool.