My harddrive is in a mess, so I decided to do a cleanup. As a part of this, I want to merge all folders containing music into one. What I want to do is, look for any *.mp3's and *.aac's on my drive and retrieve the name of the folders. Then, I want to remove any duplicate folder names and in a last step only grab the root directories. I find it hard to explain it accurately, so here's a picture of a sample tree:
root1 |--folder1 |--sub1 |--file1.mp3 |--file2.aac |--sub2 |--sub3 |--file3.mp3 |--file4.aac |--folder2 | ...contains photos and documents (no mp3/aac)... root2 |--folder3 |--file4.mp3 |--file5.aac |--folder4 |--file6.mp3
For this example, my desired output is
root1/folder1 root2/folder3 root2/folder4.
As I have only limited knowledge of bash and UNIX-tools, I have no idea how to do this. Is there a way to achieve this? I'm fine if your solution features
find, but it would be much better if
locate is used instead.