How to batch convert .wav to .mp3 with a script?

Audio Plugin Hosts and other audio software applications discussion
Post Reply New Topic
RELATED
PRODUCTS

Post

I'm looking for a tool (preferably free) that would allow to convert a large number of .wav files to .mp3 and can be triggered by command line, or one-click script at most.

Could you help with any suggetsions?
Blog ------------- YouTube channel
Tricky-Loops wrote: (...)someone like Armin van Buuren who claims to make a track in half an hour and all his songs sound somewhat boring(...)

Post

lame.exe was always the best in class. You only need to figure out the CLI options and write a .bat / .cmd / .ps1 around it.

How's your folder structure: include subdirectories?
What about adding ID3 tags with artist, title & genre?
We are the KVR collective. Resistance is futile. You will be assimilated. Image
My MusicCalc is served over https!!

Post

sox
An idiot on Set Theory:
"In some cases there is an object called red that contains everything that is red. In much the same way a pot is a plate."

Post

BertKoor wrote: Tue Sep 27, 2022 9:59 am lame.exe was always the best in class. You only need to figure out the CLI options and write a .bat / .cmd / .ps1 around it.
Not much to say about that:

Code: Select all

lame -b 320 filename.wav filename.mp3
How's your folder structure: include subdirectories?
What about adding ID3 tags with artist, title & genre?
I've got another script for that :ud:
Blog ------------- YouTube channel
Tricky-Loops wrote: (...)someone like Armin van Buuren who claims to make a track in half an hour and all his songs sound somewhat boring(...)

Post

So, problem solved then? ;-)
We are the KVR collective. Resistance is futile. You will be assimilated. Image
My MusicCalc is served over https!!

Post

Dbpoweramp Converter is what I use for this exact thing.

Post

It was more difficult than expected, but I wrote a Python script that runs lame.exe concurrently in multiple processes. Because 12 cores are better than one.

Warning: It deletes input .wavs afterwards.

Code: Select all

from asyncio import subprocess
import os
import subprocess
import multiprocessing
from multiprocessing.pool import ThreadPool

FOLDER = "G:\\Na przemiał"

# Find files

fileList = []
results = []

for name in os.listdir(FOLDER):
	if name.endswith('.wav'):
		fileList.append(name)

print("\nFound file names:\n\n" + '\n'.join(fileList))

def call_proc(name):
	""" This runs in a separate thread. """
	
	cmd = f"lame -b 320 \"{name}\" \"{name.replace('.wav', '.mp3')}\""

	p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
	out, err = p.communicate()
	print(f"Finished conversion of {name}")
	return (out, err)


pool = ThreadPool(multiprocessing.cpu_count())

for name in fileList:
	results.append(pool.apply_async(call_proc, (name,)))

# Close the pool and wait for each running task to complete
pool.close()
pool.join()
for result in results:
	out, err = result.get()

for name in fileList:

	newName = name.replace('.wav', '.mp3')

	if (os.path.exists(newName)):
		#file has been converted properly
		print(f"Deleting {name}")
		os.remove(name)
Blog ------------- YouTube channel
Tricky-Loops wrote: (...)someone like Armin van Buuren who claims to make a track in half an hour and all his songs sound somewhat boring(...)

Post Reply

Return to “Hosts & Applications (Sequencers, DAWs, Audio Editors, etc.)”