Note Mapping CSV File Icon Audio Files Renamer.py Icon

Streamlining Audio File Renaming with Python: A Practical Guide

In audio production, especially for projects involving sample libraries or virtual instruments, organizing and renaming files can be tedious and error-prone. Today, we’ll walk through a Python script that automates this task by renaming a batch of audio files in a structured format based on MIDI note mappings. This script allows you to save time, maintain consistency, and focus on the creative side of production rather than repetitive file management.

Overview of the Script

Our script is designed to rename audio files in bulk, using a MIDI note mapping in a CSV file. Here’s how it works:

Step-by-Step Guide

1. Selecting the Audio Files Directory

The script starts by prompting you to select the directory containing your .wav audio files. This is done through a graphical file picker, making it user-friendly and intuitive:

directory = get_audio_directory()

2. Listing and Sorting Audio Files

Once the directory is selected, the script searches for .wav files within it. It includes a robust sorting method, which ensures files are ordered logically by any numeric values in the filenames—a useful feature for keeping track of numbered files like “01-Kick.wav” and “02-Snare.wav.”

audio_files = list_audio_files(directory)

3. Getting User Input for the New File Format

The script then prompts you to input a desired naming format, such as “A#2, Guitar, Tremolo, RR1.” The format is flexible, allowing you to customize names while ensuring consistency across all files.

user_format = get_user_format()

4. Loading the MIDI Note Mapping from CSV

To make sure each file is labeled with the correct MIDI note, the script reads a note_mapping.csv file located in the audio files directory. This file contains mappings of MIDI note numbers to note names, helping the script understand that, for example, MIDI number 60 corresponds to “C4.”

mapping, reverse_mapping = create_note_mapping(csv_path)

5. Renaming Files Sequentially Based on MIDI Notes

Using the mappings from the CSV, the script starts renaming each audio file from the specified note. Each file receives a name based on the MIDI note number, instrument, articulation, and round-robin number. The renaming format in this example would look like: 60-Guitar_C4-Tremolo_RR1.wav.

rename_audio_files(directory, audio_files, start_note, mapping, reverse_mapping)

Key Features of the Script

Example Usage

Imagine you have a directory filled with unsorted audio samples. By running this script, you can:

This tool can significantly speed up your workflow, making it a perfect solution for audio producers working with large libraries. Whether you're building a sample pack or organizing instrument files, this script ensures your files are consistently named and easy to locate.

Closing Thoughts

Organizing audio files doesn’t have to be a painstaking chore. With this Python script, you can automate the renaming process, leaving you free to focus on the creative aspects of your project. And because it uses Python’s standard library, it's simple to set up and customize.

Ready to streamline your audio file management? Give the script a try, and enjoy a faster, more organized workflow!