I have a Music folder and the contents look like this:
Music -ArtistA -Song1.mp3 -AlbumA -Song2.mp3 -Song2.m4a -AlbumB -Song1.mp3 -Song2.mp3 -Song3.mp3 -AlbumC -Song1.mp3 -Song1.jpg -SomeFolder1 -Song1.mp3 -ArtistB -Song1.mp3 -ArtistC -Song1.mp3 -Song2.mp3 -Song3.mp3 -SomeFolder2 -Song1.jpg -Song2.jpg -SomeFolder3
I am looking for output like this:
ArtistA/Song1.mp3 ArtistA/AlbumA/Song2.mp3 ArtistA/AlbumC/Song1.mp3 ArtistA/AlbumC/SomeFolder1/Song1.mp3 ArtistB/Song1.mp3
So, I don't want directories with only one file, I want directories with only one mp3 - regardless of subdirectories or other files. I also do not want empty directories, or directories which contain more than one mp3.
I am not opposed to a shell script for Linux. I don't want to compile a program on either OS, however.
I have tried:
find . -type d -exec sh -c 'set -- "$0"/*.mp3; [ $# -le 1 ]' {} \; -print
but that gives me this output:
. ./ArtistB ./ArtistA ./ArtistA/AlbumA ./ArtistA/AlbumC ./ArtistA/AlbumC/SomeFolder1 ./ArtistC/SomeFolder2 ./ArtistC/SomeFolder3
which is close, but not exactly what I want. There are two empty folders and no filenames.