Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question is the same as http://askubuntu.com/questions/47155/reorder-files-inside-folder:

I have about 30K songs in mp3. I already organized/tagged them with Musicbrainz Picard. But Picard made an excess of folders and subfolders inside each other because of the tags. What I need now is a script to do the following inside the main music folder:

  1. To read each subfolder and move all the mp3 files inside the subfolder's folders to the main subfolder. For example:

     Music -  
       Offspring -
          Album 1 - 20 songs
          Album 2 - 30 songs
          Album 3 - 5 Songs
             Folder 1 - 2 Songs
             Folder 2 - 3 Songs
       Journey -
          Song Pack 1 - 2 Songs
               Packy 1 - 15 Songs
               Packy 2 - 20 Songs
               Packy 3 - 7 Songs
          Album 2 - 20 songs
          Whatever 3 - 10 Songs
    

After script they would be like this:

     Music -    
       Offspring - All Songs inside THIS folder. Not inside subfolders of Offspring.  
       Journey - All Songs inside THIS folder. Not inside subfolders of Journey.   

And so on..

So all the music for each subfolder of each music group should not have any more subfolders and all songs inside their respective sub-subfolders should be moved to the main sub-folder of the music group.

So when I check Music and I see the Bee Gees then I KNOW that all the songs are right there and not inside some subfolder of Bee Gees.

NOTE - In some cases there are more than 20 recursive sub-folders. An example is: Music/Lady Gaga/1/Album/Lady Gaga/2/2/2/1/1/1/1/3/3Album 2/Lady Gaga/1/1/1/SONG.mp3. In this case i want the son inside Music/Lady Gaga and eliminate the rest of the folders. Please do not take into account that the files are mp3. Just think of them as normal text files or something since what I want can also be applied to group of files inside several folders.

share|improve this question
    
"Cross-posting is strongly discouraged -- if you post on one site and then change your mind it can always be migrated to another". If you want the AU post moved here just mod flag it and the AU mods will take care of it –  Michael Mrozek Jun 8 '11 at 18:18
add comment

closed as off topic by Michael Mrozek Jun 8 '11 at 18:18

Questions on Unix & Linux Stack Exchange are expected to relate to Unix or Linux within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.