Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.


Go Back   Doom9's Forum > Programming and Hacking > Development

Thread Tools Search this Thread Display Modes
Old 18th May 2019, 01:49   #1  |  Link
Registered User
Join Date: Jun 2002
Location: Germany
Posts: 5,516
How to batch convert audio files in a portable way?

My long term goal is to learn how to do things the command line and portable way and maybe try Linux and MacOS in the future.

How would you batch convert audio files?

Here is my solution in PowerShell and only tested in Windows:

$inputFolder = "C:\Users\frank\Daten\Music Temp"
$outputFolder = "C:\Users\frank\Desktop\mp3 files"

Get-ChildItem $inputFolder |
Foreach-Object {
    $targetpath = $outputFolder + "\" + $_.BaseName + ".mp3"
    ffmpeg -i $_.FullName -b:a 320k $targetpath
GUI is fine as long as it is portable.
stax76 is online now   Reply With Quote
Old 18th May 2019, 11:41   #2  |  Link
Software Developer
LoRd_MuldeR's Avatar
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,011
Well, FFmpeg already is portable, so is this mostly a question about the scripting?

If so, I think shell script (e.g. Bash) is the way to go:

readonly input_folder="/home/johndoe/Music"
readonly output_folder="/home/johndoe/Desktop"

for source_path in "$input_folder/"*; do
    target_path="$output_folder/$(basename -s .wav "$source_path").mp3"
    ffmpeg -i "$source_path" -b:a 320k "$target_path"
This should work on any Unix and Unix-like OS (e.g. Linux or macOS ) out of the box. On Windows, you can use MSYS/MinGW or Cygwin, for example (I recommend giving MobaXterm a try to get started).

Could even use BusyBox for Win32 as a minimal Unix shell on Windows. And, of course, Microsoft's PowerShell is more or less "portable" now, as well...
There was of course no way of knowing whether you were being watched at any given moment.
How often, or on what system, the Thought Police plugged in on any individual wire was guesswork.

Last edited by LoRd_MuldeR; 18th May 2019 at 11:54.
LoRd_MuldeR is offline   Reply With Quote
Old 18th May 2019, 13:17   #3  |  Link
qyot27's Avatar
Join Date: Nov 2005
Location: Florida
Posts: 1,029
Another Bash example. This is the script I use to process my audio CD backups:
#!/bin/bash -x
set -e
for n in *.wav ; do
flac --no-preserve-modtime -V -8 "$n"

cd ..
for n in *.wav ; do
qaac --abr 192 --no-smart-padding --rate keep -o "MP4/${n%.*}.m4a" "$n"

for n in *.wav ; do
opusenc  --bitrate 192 --comp 10 --framesize 60 --ignorelength "$n" "Opus/${n%.*}.opus"
Not that I'm saying anything for/against using the format tools, it was more about the shell substitution and regex abilities ( ${n%.*} ).

Last edited by qyot27; 18th May 2019 at 13:20.
qyot27 is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 14:22.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.