So I have a music folder full of different file formats all mixed together. It IS well-structured: Music/[Artist Name]/[Album Name], with compilation albums in a folder called "Various". Some folders contain just .mp3, .m4a, or .flac files, and some have multiple versions of the album in different file formats. There are also of course various .jpegs of cover art and many of the artist folders contain a .jpeg of the artist's portrait, and there are also many miscellaneous .cue and .log files and other junk.
What I want to end up with is a separate music folder for .flac files, retaining the existing folder structure, removeing them from the existing library. I don't want to end up with empty folders in my current library either, where the album was only in flac. In cases of album folders with multiple formats, I want to move the flacs to the new library along with the cover art, but of course keep the existing cover art in place as well.
I haven't been able to find an application capable of handling this, but I figured a shell script could probably handle it. However I am pathetic with bash and really don't want to break my library.
The files are on a remote disk that I can access with mac, windows, or linux so any approach is good.
Just to fully clarify, here's the logic I'm hoping to code:
Find each subdirectory of /Music that contains .flac files
Copy each of these directories in their entirety (and intermediate parent directories) to a new location in /FLAC, but exclude other audio filetypes (.mp3, .m4a, etc.) from the copy.
If the directory has no other audio filetypes than .flac, delete the entire directory. If it DOES have other audio files, just delete the .flac files.
Do one final sweep through all of /Music to delete any directory that contains no audio files in itself or any subdirectory.