A minimalist Python CLI tool for converting files between formats within the same category. This tool acts as a thin wrapper around existing command-line tools (FFmpeg, ImageMagick, LibreOffice) to provide a unified interface for file conversion.
- Category-based conversion: Only converts files within the same category (e.g., image to image, audio to audio)
- Multiple format support: Supports audio, video, image, document, spreadsheet, and presentation formats
- Simple CLI: Clean, intuitive command-line interface
- Extensible design: Easy to add new formats by updating the category mappings
This tool requires the following external command-line tools to be installed and available in your PATH:
- FFmpeg: For audio and video conversions
- ImageMagick: For image conversions
- LibreOffice: For document, spreadsheet, and presentation conversions
Installation instructions:
- macOS:
brew install ffmpeg imagemagick libreoffice - Linux (Ubuntu/Debian):
sudo apt-get install ffmpeg imagemagick libreoffice - Windows: Download installers from the respective project websites
- Python 3.11 or higher
-
Clone this repository:
git clone <repository-url> cd anything2anything
-
Create a virtual environment:
python3 -m venv .venv
-
Activate the virtual environment:
# macOS/Linux source .venv/bin/activate # Windows .venv\Scripts\activate
-
Install the package:
pip install .For development (editable install):
pip install -e .
anything2anything INPUT_PATH OUTPUT_PATH [options]Note: For backwards compatibility,
python anything2anything.py ...still works, but the recommended way is to use theanything2anythingcommand after installation.
--force,-f: Overwrite output file if it already exists--verbose,-v: Print detailed information about the conversion process--help: Show help message
# Convert HEIC to JPG
anything2anything inputs/photo.heic outputs/photo.jpg
# Convert JPG to WebP with verbose output
anything2anything inputs/image.jpg outputs/image.webp --verbose# Convert M4A to MP3
anything2anything inputs/audio.m4a outputs/audio.mp3
# Convert WAV to M4A
anything2anything inputs/recording.wav outputs/recording.m4a# Convert MOV to MP4
anything2anything inputs/video.mov outputs/video.mp4
# Convert with force overwrite
anything2anything inputs/video.mp4 outputs/video.mov --force# Convert DOCX to ODT
anything2anything inputs/document.docx outputs/document.odt
# Convert DOC to RTF
anything2anything inputs/document.doc outputs/document.rtf# Convert XLSX to ODS
anything2anything inputs/spreadsheet.xlsx outputs/spreadsheet.ods
# Convert CSV to XLSX
anything2anything inputs/data.csv outputs/data.xlsx# Convert PPTX to ODP
anything2anything inputs/presentation.pptx outputs/presentation.odp.mp3- MPEG Audio Layer 3.wav- Waveform Audio.m4a- MPEG-4 Audio
.mov- QuickTime Movie.mp4- MPEG-4 Video
.heic- High Efficiency Image Container.jpg,.jpeg- JPEG Image.gif- Graphics Interchange Format.icns- Apple Icon Image.webp- WebP Image.avif- AV1 Image File Format.svg- Scalable Vector Graphics.png- Portable Network Graphics
.csv- Comma-Separated Values.ods- OpenDocument Spreadsheet.xlsx- Microsoft Excel (OpenXML).xls- Microsoft Excel (Legacy).xlsm- Microsoft Excel Macro-Enabled
.odp- OpenDocument Presentation.ppt- Microsoft PowerPoint (Legacy).pptx- Microsoft PowerPoint (OpenXML)
.docx- Microsoft Word (OpenXML).doc- Microsoft Word (Legacy).odt- OpenDocument Text.txt- Plain Text.rtf- Rich Text Format.pdf- Portable Document Format
The tool provides clear error messages for common issues:
- Unsupported format: If the input or output format is not supported
- Category mismatch: If attempting to convert between different categories (e.g., image to audio)
- Missing tools: If required external tools (FFmpeg, ImageMagick, LibreOffice) are not found
- File not found: If the input file does not exist
- Conversion failure: If the underlying tool fails to convert the file
Use the --verbose flag to see detailed error output from the underlying tools.
anything2anything/
├── anything2anything.py # Compatibility shim (backwards compatibility)
├── pyproject.toml # Package configuration and build metadata
├── src/ # Source code directory
│ └── anything2anything/ # Main package
│ ├── __init__.py
│ ├── cli.py # CLI entry point
│ ├── categories.py # Category definitions and extension mapping
│ ├── converters.py # Backend conversion functions
│ └── dispatcher.py # Conversion routing logic
├── requirements.txt # Python dependencies (for reference)
├── .gitignore # Git ignore patterns
├── inputs/ # Directory for sample inputs
├── outputs/ # Directory for sample outputs
└── README.md # This file
For development, install the package in editable mode:
pip install -e .This allows you to make changes to the code and test them immediately without reinstalling.
The codebase is designed to be simple and extensible. To add support for new formats:
- Add the extension to
EXTENSION_TO_CATEGORYinsrc/anything2anything/categories.py - If needed, add a new converter function in
src/anything2anything/converters.py - Update the dispatcher if a new category is added