How can I convert WAV to Apple lossless in the terminal?

10

5

I have a lot of WAV files that I do not wish to import into iTunes to convert. There are too many. I would like a way to convert these to Apple lossless in the terminal before importing to iTunes.

Richard Hoskins

Posted 2009-09-28T15:04:54.783

Reputation: 10 260

Answers

16

You'll need to make a short bash for loop in a script (or xargs) but the command in question you care about is:

afconvert -d alac in.wav out.m4a

More info can be found by running man afconvert or afconvert -h.

Chealion

Posted 2009-09-28T15:04:54.783

Reputation: 22 932

afconvert has a pretty limited range of input formats, I'd suggest using ffmpeg which has the builtin alac encoder too but supports tons of audio formats and it also tries to keep the metadata from the source as much as possible. e.g. ffmpeg -i input.whatever -vn -c:a alac -f ipod output.m4a – Meow – 2018-03-30T15:09:46.070

1Simple one line loop example: for file in *.wav; do afconvert -d alac "$file" "${file%wav}m4a"; done – flori – 2013-08-10T13:40:56.823