I am unable to resurrect old posts (for very good reasons).
This post from 2010 is essentially my exact question with some slight changes to the input and output folder/file locations.
Here is the text of the linked forum post (reformatted), for reference. I have modified the details of the post so they apply to my specific parameters. The quoted items are generic placeholders if that isn't immediately evident: (I recognize alac is lossless. "compressed" is the folder itunes watches for any compatible files and has mp3's in it, as well.)
/home/storage/music/lossless/"Artist"/"Album"/"Song.flac"
I would like to convert these to alac's (.m4a) in order to play them on my iPhone. I have a script that will convert all the flac's in a folder to alac .m4a's and it looks like this:
Code:
for i in *.flac; do ffmpeg -i "$i" -acodec alac "`basename "$i" .flac`.m4a"; done;
What I would like to do is a write a script that would just run ffmpeg, recursively, in every folder found in /home/storage/music/lossless.
Then, I'd like to append a script to move all the newly created alac's to another folder in a way that retains the current structure so I could end up with something like:
input = /home/storage/music/lossless/"Artist"/"Album"/"Song.flac" and output = /home/storage/music/compressed/"Artist"/"Album"/"Song.m4a"
Any suggestions/advice/feedback would be appreciated.
Thanks for your time,
Sohex
The converted m4a's show up in the directory containing Music and Music_too (or FLAC and ALAC if you will) instead of in the appropriate location, how can I fix that?
Either replace "`basename "${i/Music/Music_too}" .flac`.m4a" with "`diame ${i/Music/Music_too}"`/`basename "$i" .flac`.m4a" or edit $i in two steps using neither diame nor basename, like o=${i/Music/Music_too}; o=${o%.flac%.m4a} and then use "$o" in the ffmpeg command.
Code:
for i in Music/*/*/*.flac; do o=${i/Music/Music_too}; o=${o%.flac%.mp4}; ffmpeg -i "$i" -acodec alac "$o"; done
Code:
for i in Music/*/*/*.flac; do o=${i/Music/Music_too}; o=${o%.flac%.mp4}; echo ffmpeg -i "$i" -acodec alac "$o"; done
Code:
for i in /home/storage/music/lossless/*/*/*.flac;
If possible, an additional step that checks the respective "compressed" folder for .m4a's already existing would aid in being able to reuse this single script each time I've added files to the "lossless" folder. Perhaps, as a CRON job that is run nightly. This is not a priority or needed at all, just a hopeful wish, if easily executed.
Any help would be greatly appreciated.
برچسب:
نویسنده: استخدام کار