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. |
18th May 2019, 01:49 | #1 | Link |
Registered User
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
|
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: Code:
$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 }
__________________
https://github.com/stax76/software-list https://www.youtube.com/@stax76/playlists |
18th May 2019, 11:41 | #2 | Link |
Software Developer
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
|
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: Code:
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" done 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...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ Last edited by LoRd_MuldeR; 18th May 2019 at 11:54. |
18th May 2019, 13:17 | #3 | Link |
...?
Join Date: Nov 2005
Location: Florida
Posts: 1,420
|
Another Bash example. This is the script I use to process my audio CD backups:
Code:
#!/bin/bash -x set -e cd FLAC for n in *.wav ; do flac --no-preserve-modtime -V -8 "$n" done cd .. for n in *.wav ; do qaac --abr 192 --no-smart-padding --rate keep -o "MP4/${n%.*}.m4a" "$n" done for n in *.wav ; do opusenc --bitrate 192 --comp 10 --framesize 60 --ignorelength "$n" "Opus/${n%.*}.opus" done Last edited by qyot27; 18th May 2019 at 13:20. |
|
|