Actually, I need help with one more expression too...
I need a second one to serve as the iTunesFileKey field for MCiS. This field is how MCiS can map to an external sync location (like a cache) for file types that aren't supported by iTunes.
Anyhow... I need this (it is similar to the above task, but not the same): For any given file, I need to spit out its filename, modified to replace the "M:\" part, with "M:\iTunes_cache\". However, I also need to change the file extensions for non-supported file types to the supported converted extension.
So, using the first of those examples above, the output would be just:
M:\iTunes_cache\Audio\Audiobook\Gibson, William\Neuromancer\02 - Neuromancer 02-12.mp3
However, if the "input filename" happened to be a FLAC, WAV, OGM or whatever audio file, it would then "become" a MP3 instead, like so...
Input files:
M:\Audio\Music\B\The Beatles\Abbey Road\12 - Polythene Pam.flac
M:\Audio\Music\G\Grateful Dead\1977-05-08 - Barton Hall, Cornell University, Ithaca, Ny (Ma\1\04 - They Love Each Other.ogm
M:\Audio\Music\A\Abba\Gold - Greatest Hits\01 - Dancing Queen.mp3
M:\Audio\Audiobook\Martin, George RR\Song of Ice and Fire 4 - A Feast For Crows\08 - Part 008.m4b
Output:
M:\iTunes_cache\Audio\Music\B\The Beatles\Abbey Road\12 - Polythene Pam.mp3
M:\iTunes_cache\Audio\Music\G\Grateful Dead\1977-05-08 - Barton Hall, Cornell University, Ithaca, Ny (Ma\1\04 - They Love Each Other.mp3
M:\iTunes_cache\Audio\Music\A\Abba\Gold - Greatest Hits\01 - Dancing Queen.mp3
M:\iTunes_cache\Audio\Audiobook\Martin, George RR\Song of Ice and Fire 4 - A Feast For Crows\08 - Part 008.m4b
As you can see, I'm converting FLAC files to MP3s, and OGMs to MP3s, but leaving the M4B file alone. In other words, I'm setting MC to sync using the Handheld sync to create these files, with the supported file types list set to: mp3;mp4;m4a;m4v;m4p;m4b;m4r;jpg
I need those "supported types" to have their iTunes key field match the original file name exactly with only the M:\iTunes_cache\ folder added at the beginning, but for all other unsupported types (mostly Flac and OGM files for audio), I need the output to both add the folder and change the file type to .mp3. Does this make sense?
I have an expression started that does exactly this, but the way I'm doing it, I have to test for each and every possible file type manually, like this:
IfElse( IsEqual([File Type],flac,1), Replace([Filename (path)],M:\,M:\iTunes_cache\)Replace([Filename (name)],flac,mp3), 1, Replace([Filename (path)],M:\,M:\iTunes_cache\)[Filename (name)] )
That's just for flac. I need to turn Flac, OGM, and WAV into MP3 (but leave M4A and M4B alone). I don't think my way of doing it is very clean, though... Right now, my sync list only includes those three types (flac, ogm, and wav) that would need converted, but what if a WMA file or something slips in?
So, it would be better to do it logically this way:
If File Type is (MP3, M4B, M4R, M4A, etc) then just add the iTunes_cache folder to the beginning of the path.
ELSE Output the path with the new folder at the beginning, and change the file extension to mp3.
Once I get that working, I'd like to modify it to work on video too (AVI becoming MP4, but M4V staying M4V).