Keep music library (apple lossless) in sync and converted as another format (flac)

0

My music library is arranged like:

/data/music/Artist_-_Album[alac]/*.m4a

I need to be able to keep a copy of these in another format (apple lossless) and I'd want that like:

/data/music/Artist_-_Album[flac]/*.flac

This one liner is good at traversing directories and converting items to flac, but it leaves all of the files in the source directory... not optimal.

for f in /data/music/**/*.m4a; do avconv -i "$f" "${f%.m4a}.flac"; done

How can I change/edit/add to this script to make the output files to into a different folder that is named appropriately as shown above?

AaronJAnderson

Posted 2014-01-01T20:39:20.210

Reputation: 283

is there a specific reason you want to seperate the m4a from the flac files? ... also, could the folder with the m4a's in it contain folders too (i.e. /data/music/**/m4a/*.m4a and /data/music/**/flac/*.flac)? – txtechhelp – 2014-01-01T22:50:26.270

Why separate them? I don't want duplicates. I don't want to offsite backup the m4a's, etc. Just easier to keep them somewhere else. – AaronJAnderson – 2014-01-02T00:25:19.057

Valid concerns :) .. Do you care if there's 2 separate folders in the main folder (i.e. /data/music/*/m4a/*.m4a and /data/music/*/flac/*.flac)? If not you can use the same script from above (with some adjustments), otherwise a little more script fu is needed for an answer – txtechhelp – 2014-01-02T00:54:00.040

I really want them completely separate. The output location will probably be a different mount point completely. – AaronJAnderson – 2014-01-02T01:09:45.497

No answers