In my music directory I have multiple duplicate files of both .mp3 and .flac format. Consider:
/dir1/music1.flac
/dir1/music1.mp3
/dir2/music1.mp3
/dir2/music2.MP3
/dir2/music2.flac
/dir2/music3.mp3
music1.flac and music1.mp3 in dir1 are the same song in different formats, but music1.mp3 in dir1 and dir2 may not be (same name, but released on different albums).
I wish to traverse multiple subdirectories finding files with an identical prefix but different extensions, and then delete just the mp3 files. As such, for the above directories, I'd be left with:
/dir1/music1.flac
/dir2/music1.mp3
/dir2/music2.flac
/dir2/music3.mp3
I've tried to use the find command with the logical AND, but to no avail. Some failures on my part:
find ./ -regex '.*\(mp3\|flac\)$'
find . -type f -name "*mp3" -and -name "*flac"
Any help is appreciated. I've solved similar problems with posted stackoverflow code on my own, but I'm stumped on this one. YOU GUYS ARE GREAT.