Convert a bunch of .wav files to AAC (.m4a), while keeping them in the same sub-folders

Efficiently Converting Multiple WAV Files to AAC (.m4a) Within Nested Folders on Windows

Managing large collections of audio files can be challenging, especially when you need to convert numerous files across various subfolders while maintaining their directory structure. If you’re looking to convert all your WAV files to AAC (.m4a) format with variable bit rate (VBR), or alternatively to high-quality MP3 (320 kb/s), and preserve the original folder hierarchy, this guide provides an effective solution tailored for Windows users comfortable working with command-line tools.

Overview

In this tutorial, we will:

  • Recursively locate all WAV files within a main directory and its subdirectories.
  • Convert each WAV file to AAC (.m4a) with VBR encoding.
  • Keep the converted files in the same location as their source files.
  • Handle folder names with spaces and non-ASCII characters.

Prerequisites

  • FFmpeg: A powerful, open-source multimedia framework that supports audio conversion with various codecs and options. Download and install FFmpeg from https://ffmpeg.org/download.html. Ensure that the FFmpeg executable (ffmpeg.exe) is added to your system’s PATH environment variable for easy command-line access, or note its installation directory for direct reference.

Step-by-Step Guide

1. Prepare Your Directory

Ensure your main folder containing the WAV files and subfolders is organized and backed up if necessary, to prevent unintentional data loss during batch processing.

2. Use Command Prompt with Proper Encoding Support

Open the Command Prompt. If your folder names contain non-ASCII characters, consider using a code page that supports Unicode:

bash
chcp 65001

This enables UTF-8 encoding, helping the command prompt correctly handle special characters.

3. Batch Conversion Script

Navigate to your main directory:

bash
cd path\to\your\main\folder

Replace path\to\your\main\folder with the actual path.

Now, execute the following command:

bash
for /r %F in (*.wav) do (
ffmpeg -i "%F" -c:a aac -qscale:a 0 -map_metadata 0 -y "%~dpnF.m4a"
)

Explanation:

  • /r – Recursively processes files in all subdirectories.
  • `%F

Share this content:

Leave a Reply

Your email address will not be published. Required fields are marked *