Folder Cleaner is a Python script designed to find and delete empty folders within a specified directory. It uses multithreading for efficient folder traversal and deletion, and it provides logging capabilities to track operations and errors.
- Multithreaded Execution: Utilizes ThreadPoolExecutor for concurrent operations, enhancing performance by processing multiple folders simultaneously.
- Logging: Implements logging to capture informational messages, errors, and debug information based on user-defined debug mode.
- Timestamped Output: Saves a list of deleted folders with a timestamp to facilitate tracking and auditing.
Python 3.x argparse library (typically included with Python standard library) logging library (included with Python standard library)
- Clone the repository:
git clone https://github.com/yourusername/folder-cleaner.git
cd folder-cleaner
- Install dependencies (if any):
pip install -r requirements.txt
python folder_cleaner.py <path> [-o OUTPUT_FILE] [--debug]
Arguments : Required. Path to the directory where empty folders will be searched and deleted. -o OUTPUT_FILE, --output OUTPUT_FILE: Optional. Output file path for saving the list of deleted folders. Default is output/deleted_folders.txt. --debug: Optional flag to enable debug mode. Displays detailed debug messages.
Find and delete empty folders in C:\Projects directory, enable debug mode, and save deleted folders to logs/deleted_folders.log:
python folder_cleaner.py C:\Projects -o logs/deleted_folders.log --debug
Logs are generated in the console and optionally in a log file (logs/folder_cleaner.log by default). Debug mode (--debug) enables detailed logging, including permission errors and folder operations.
Ensure proper permissions are set for deleting folders, especially on systems with restricted access. Use caution when deleting folders as data loss may occur if not used correctly.
This script is designed to append a specified extension to files in a given directory if they don't already have a recognized extension. The default extension to append is .mp4
, but this can be easily changed.
- Checks files in a specified directory.
- Appends a target extension (default
.mp4
) to files without a recognized extension. - Utilizes the Strategy design pattern for handling files with known and unknown extensions.
- Comprehensive error handling for robustness.
- Extensible and maintainable code with detailed comments and type hints.
The script recognizes a wide range of common file extensions including but not limited to:
- Document formats:
.pdf
,.doc
,.docx
,.txt
,.xls
,.xlsx
,.ppt
,.pptx
- Media formats:
.mp3
,.mp4
,.mkv
,.avi
,.wav
,.mov
,.jpg
,.jpeg
,.png
,.gif
,.bmp
,.tif
,.tiff
- Archives and executables:
.zip
,.rar
,.tar
,.gz
,.iso
,.exe
,.msi
- Web and code files:
.html
,.css
,.js
,.json
,.xml
,.sql
,.py
,.java
,.class
,.jar
- Configuration and system files:
.ini
,.cfg
,.log
,.bat
,.dll
,.sh
,.bin
,.key
,.pem
- Clone the repository or download the script.
- Open a terminal and navigate to the directory containing the script.
- Run the script with the following command:
python extension_util.py <directory_path>
Replace <directory_path>
with the path to the directory you want to process.
python extension_util.py /path/to/directory
This project contains a Python script to ping a website repeatedly until it responds successfully. The script includes retry logic with exponential backoff and provides logging for status updates and errors.
- Pings a specified website URL until a successful response is received.
- Logs status updates and errors.
- Implements retry logic with exponential backoff.
- Cross-platform compatibility (no OS-specific dependencies).
requests
library
- Clone the repository:
git clone https://github.com/your-username/website-ping-utility.git
cd website-ping-utility
``
## Usage
To use the script, run the following command:
```bash
python ping_util.py <url>
Replace with the website URL you want to ping.
python ping_util.py https://example.com
This project is licensed under the MIT License - see the LICENSE file for details.