A collection of Python utilities designed to automate common daily tasks such as file organization and media conversion for web optimization.
- Automatically organizes files in a directory by their extensions
- Creates organized folder structure within an "OrganizedFiles" subdirectory
- Groups files by file type (e.g., all
.pdf
files go into apdf
folder) - Perfect for cleaning up cluttered download folders or project directories
- Batch converts media files to web-optimized formats
- Images: Converts PNG, JPG, JPEG → WebP format
- Videos: Converts MP4, MOV, AVI, MKV → WebM format
- Audio: Converts MP3, WAV → OGG format
- Creates automatic backups of original files in
old_media
folders - Recursively processes subdirectories
- Significantly reduces file sizes while maintaining quality
- Python 3.6+
- Dependencies listed in
requirements.txt
-
Clone this repository:
git clone <repository-url> cd py_scripts
-
Install required dependencies:
pip install -r requirements.txt
Organize files in a specific folder:
python file_organizer.py <folder_path>
Example:
python file_organizer.py Downloads
This will create an "OrganizedFiles" folder inside your Downloads directory and sort all files into subfolders based on their extensions.
Convert media files to web-optimized formats:
python3 media_to_web.py <folder_path>
Example:
python3 media_to_web.py ~/Pictures/vacation-photos
This will:
- Convert all images to WebP format
- Convert all videos to WebM format
- Convert all audio files to OGG format
- Create backups of original files in
old_media
folders - Process all subdirectories recursively
- Works with any file extension
- Creates folders based on file extensions automatically
Media Type | Input Formats | Output Format |
---|---|---|
Images | PNG, JPG, JPEG | WebP |
Videos | MP4, MOV, AVI, MKV | WebM |
Audio | MP3, WAV | OGG |
- Backup Safety: The media converter automatically creates backups before conversion
- File Removal: Original files are removed after successful conversion (backups remain)
- Error Handling: Failed conversions are logged and original files are preserved
- Web Optimization: Converted formats are optimized for web use with smaller file sizes
Downloads/
├── OrganizedFiles/
│ ├── pdf/
│ │ ├── document1.pdf
│ │ └── document2.pdf
│ ├── jpg/
│ │ ├── photo1.jpg
│ │ └── photo2.jpg
│ └── txt/
│ └── notes.txt
└── (other unorganized files remain here)
Photos/
├── old_media/ # Backup folder
│ ├── IMG_001.jpg
│ └── video.mp4
├── IMG_001.webp # Converted image
└── video.webm # Converted video
This project is licensed under the MIT License - see the LICENSE file for details.
Issa El Mokadem
These scripts are designed to make file management and web optimization tasks more efficient and automated.