Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a bunch of directories in a structure like this:

-Music
  -Artist1
    -Album1
    -Album2
  -Artist2
    -Album1
    -Album3
  -Artist3
    -Album2
    -Album4

All the directories will contain unique files. I would like to reorganise this directory so that the artist directories are removed from the structure:

-Music
  -Album1
  -Album2
  -Album3
  -Album4

I was thinking of a pattern like ^[^\/]+\/ but I'm terrible at regex, and how to make it actually do something with the mv command.

share|improve this question
    
Your Album1 of Artist1 will replace Album1 of Artist2 and this would happen to all multiple copies. Is that good for you? –  vishram0709 Nov 21 '13 at 13:07
    
yep, I expect the new Album1 to contain files that were in any of the old Album1 directories –  Matt Nov 21 '13 at 16:23

3 Answers 3

If you have enough space to temporary make a copy you can simply try this:

mkdir Music_new
cp -R Music/*/* Music_new
share|improve this answer
    
You don't need a temp copy, just do mv Music/*/* Music_new && mv Music_new Music. –  terdon Jan 6 at 11:43
cd Music #Go to Music
mv */* . #Move all Album directories to Music
rmdir *  #Delete all empty directories, that is, Artist ones
share|improve this answer

You can use this.

mv Music/*\/* Music/

and then you can remove Album directories.

share|improve this answer
    
You don't need (or want) to escape the /. –  terdon Jan 6 at 11:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.