14. March 2015 · Comments Off on Automate mp3 File Concatenation with Windows Command-line Tools · Categories: Audio, Command-line Tools, Windows · Tags: batch files
Last updated on 12/12/2022

Although it requires a bit more technical effort than GUI-based applications, merging mp3 files with the command-line allows for a faster and more complete merging process and more flexibility and customization options. This guide demonstrates how to use a batch file and free Windows command-line tools to concatenate two or more mp3 files, preserve the ID3 metadata, and repair and verify the integrity of the combined file. The information in this guide was tested on system running XP SP3 32-bit and should be similar for other Windows versions.

merging mp3s

Command-line vs GUI tools

Command-line tools generally provide more options than GUI-based tools and that’s especially true for tools working with complex SW such as media files, which can be created with many different types of codecs, containers, and formats. Most GUI-based tools use command-line tools on the back-end, but GUIs are rarely able to incorporate all the possible combinations of complex commands and options of those tools into their designs. It’s difficult to design GUI’s that can accomplish difficult tasks and still be easy to use. Because GUI-based application designs are often driven primarily for ease-of-use and wide appeal, functionality and complexity are necessarily reduced in order to accomplish those goals. Command-line tools are the opposite, they are more difficult to learn and to use, but are generally able to accomplish a wider and more sophisticated range of tasks.

Command-line

Advantages – faster execution, specialized tasks can be accomplished by executing a single script, flexibility/customization (adding tools, changing options, etc.), free, uses less system resources

Disadvantages– requires coding or understanding code, takes more time and effort to configure, less intuitive

GUI-based

Advantages – quicker learning curve, more intuitive visually and for multitasking, more complete viewing and listing of information, easier switching between commands

Disadvantages – slower execution (additional programs are often required  for processing ID3 tags or to repair VBR headers), requires more system resources (video, drivers, mouse, etc.), limited options for advanced tasks (especially for free versions), limited availability of easy-to-use but highly configurable applicaions

Command-line Tools for this Guide

The command-line tools used in this guide are:

MP3Wrap (ver 0.5) – Wraps two or more mp3 files into a single file. The command-line executable is mp3wrap.exe.

ID3 mass tagger (ver 0.78) – Copies the ID3 tag to the merged file. This is the download link for the older freeware version, which is the version used in this guide. A newer version (1.21.25) is available here for both 32-bit and 64-bit systems, but it non-free shareware. It includes a GUI and a command-line version.

MP3Val (ver 0.1.8) – Validates and fixes MPEG stream, frame, and header errors. Includes both GUI and command-line versions. The command-line executable is mp3val.exe.

Because MP3Wrap strips and replaces the ID3 tags with its own information, ID3 is used to copy the tags from one of the files. MP3Val repairs any errors in the pre-merged files copied into the merged file or produced during the merging process.

Command-line Examples:

Command-line syntax useage for this guide and in the batch script:

Merge Files

The batch file provides an option to use either the Windows command-line or MP3wrap to merge the files.

The command to merge mp3 files with Windows command-line:

copy /b file1.mp3+file2.mp3+file3.mp3 outputfile.mp3

/b = binary file

Command to merge mp3 files with MP3wrap:

mp3wrap outputfile.mp3 file1.mp3 file2.mp3 file3.mp3

additional commands for MP3Wrap (ver 0.5): mp3wrap_cmd_help:

Copy Tags

The command-line syntax to copy the ID3 tags from input file1 to the output file with ID3:

id3.exe -D file1.mp3 outputfile.mp3

-D = duplicate tags from filename

additional commands for ID3 (ver 0.78): id3_078_help

Fix and Validate

Command-line syntax to fix and validate the output file with MP3Val:

mp3val outputfile.mp3 -f -nb -si

-f = try to fix errors

-nb = delete .bak files (suitable with -f)

-si = suppress INFO messages

additional commands for MP3Val (ver 0.1.8): mp3val_cmd_help

Merging mp3 Files: Process

Steps

If using the provided batch file (see below), two steps are required.

1. Prepare the mp3 files

Ensure that the mp3 files to be merged have the same frequency, bitrate, and MPEG coding and layering. Otherwise, the output file may contain non-apparent errors, even if no errors were displayed during the merging process.

2. Drag and drop the mp3 files onto the batch file to merge

Drag and drop the mp3 files all at once and in the order to be processed by the batch script. Rename/renumber the files as necessary to obtain the right order.

Batch File Processing Steps:

  1. Display the order of the mp3 files to be processed
  2. Ask the user to select between merging the files with the Windows command-line or MP3Wrap
  3. Merge the mp3 files into a temp file, “temp_MP3WRAP.mp3”
  4. Transfer the ID3 tags from the first mp3 file to the temp file with ID3
  5. Fix and validate the temp file with MP3Val
  6. Rename the temp file to the first mp3 file and append “_merged” to the file name
  7. Exit

Example Batch File:

Ensure that the file extension is changed to “bat” before using.

mergeMP3_cects.bat

References:

blogferret.com – id3.exe – ideal tool for tagging and renaming MP3 files

alexenglish.info – Concatenating MP3 Files in Linux

cephas.net – Merge multiples MP3 files into one

ghacks.net – ID3 Mass Tagger

Share
suggest
report
">Bear

Bad Behavior has blocked 1326 access attempts in the last 7 days.

jobs