Last active
November 20, 2021 02:24
-
-
Save deviationist/ea621b10ad24a4b7a1cec9befcc2891b to your computer and use it in GitHub Desktop.
FFMPEG audio convert script (FLAC ➜ AIFF, WAV ➜ AIFF, M4A ➜ MP3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| toConvertFolder="to-convert/" | |
| convertedFolder="converted/" | |
| mkdir -p $convertedFolder | |
| # FLAC to AIFF | |
| find $toConvertFolder -type f -name "*.flac" | while read line; do | |
| newFilename="${line/%.flac/.aiff}" | |
| printf "From ${line}\n" | |
| printf "To ${newFilename}\n" | |
| ffmpeg -y -nostdin -i "${line}" -write_id3v2 1 -c:v copy "${newFilename}" && rm "${line}" && mv "${newFilename}" "${convertedFolder}" | |
| done | |
| # WAV to AIFF | |
| find $toConvertFolder -type f -name "*.wav" | while read line; do | |
| newFilename="${line/%.wav/.aiff}" | |
| printf "From ${line}\n" | |
| printf "To ${newFilename}\n" | |
| ffmpeg -y -nostdin -i "${line}" -write_id3v2 1 -c:v copy "${newFilename}" && rm "${line}" && mv "${newFilename}" "${convertedFolder}" | |
| done | |
| # M4A to MP3 | |
| find $toConvertFolder -type f -name "*.m4a" | while read line; do | |
| newFilename="${line/%.m4a/.mp3}" | |
| printf "From ${line}\n" | |
| printf "To ${newFilename}\n" | |
| ffmpeg -y -nostdin -i "${line}" -c:v copy -c:a libmp3lame -q:a 4 "${newFilename}" && rm "${line}" && mv "${newFilename}" "${convertedFolder}" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment