Converting .mp3 to AAC and FLAC to ALAC

I have been working on a rule that searches the /Downloads/ folder for music files and then converts them and sends them to the "Automatically Add to iTunes" Folder. I have been unable to locate/determine an efficent way to convert the files. I have tried ffmpeg and afconvert scripts in bash with no success. Does anyone have any ideas or suggestions that would help solve the issue? Surely someone else has thought of this before 
