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.
Our script is designed to rename audio files in bulk, using a MIDI note mapping in a CSV file. Here’s how it works:
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()
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)
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()
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)
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)
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.
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!