This is a Bash script that converts various audio file formats (e.g., .wav, .flac, .ogg, .aac, .m4a, .alac, .aiff, .opus) to .mp3. The script supports converting a single file or multiple audio files in a directory, with options for recursive directory search, skipping already existing files, and preserving metadata. It also includes a "no confirmation" mode for automatic overwriting of files.
Current version: 0.0.1
-
Ensure you have FFmpeg installed on your system. FFmpeg is used for audio file processing.
-
On Ubuntu/Debian:
sudo apt install ffmpeg
-
On Mac (using Homebrew):
brew install ffmpeg
-
On Windows:
Download FFmpeg from here and follow the instructions to set it up.
-
-
Download the script from this repository and make it executable:
chmod +x audio2mp3.sh
You can use the script to convert individual audio files or entire directories of audio files. Below are the command options and examples of usage:
Usage: ./audio2mp3.sh -f <input_file> [-o <output_path>] | -d <directory> [-o <output_directory>] [-r] [-c] [-s] [-nc]
Options:
Required Flags (Must provide either -f or -d):
-f, --file <input_file> Convert a single file.
-d, --directory <directory> Convert all supported files in a directory.
Optional Flags:
-o, --output <output_path> Specify output file (if using -f) or output directory (if using -d).
-r, --recursive Process directories recursively.
-c, --copy Convert without re-encoding if possible.
-s, --skip-existing Skip existing files without prompt.
-nc, --no-confirm Automatically overwrite existing files without asking.
-h, --help Show this help message.Convert a single audio file to MP3:
./audio2mp3.sh -f input.wav -o output.mp3Convert all supported audio files in a directory:
./audio2mp3.sh -d /path/to/audio/filesRecursively search and convert all audio files in a directory and subdirectories:
./audio2mp3.sh -d /path/to/audio/files -rConvert an audio file without re-encoding (if it is already in MP3 format):
./audio2mp3.sh -f input.mp3 -cSkip existing files during conversion:
./audio2mp3.sh -d /path/to/audio/files -sAutomatically overwrite files without confirmation:
./audio2mp3.sh -d /path/to/audio/files -ncThis project is licensed under the MIT License. See LICENSE for more details.
Pull requests are welcome. For major changes, please open an issue first to discuss what you'd like to change. Make sure to update tests as appropriate.