-1

I have too many files being in directories with same name EXAMPLE:

~/foo/bar/foo/bar/1.flac
~/foo/bar/foo/bar/bar/foo/foo/0.flac

I want to have

~/foo/bar/0.flac
~/foo/bar/1.flac
user83873
  • 27
  • 1
  • downvote more, what do you wanna accomplish? – user83873 Sep 11 '14 at 17:54
  • The question is really ambiguous, do you want ~/foo/bar/FILE all the time? How should the script know when to move files or when to leave them alone? You aren't helping people answer your question, you're saying "do this for me". – alexmherrmann Sep 11 '14 at 18:05
  • @alexhairyman yes.The script should know to move FILE up to /foo/bar whatever foo and bar is. – user83873 Sep 11 '14 at 18:46
  • -1 for me too. "I haz no code for u" without more details. – Michael Durrant Sep 11 '14 at 21:02
  • possible duplicate of [Flattening a nested directory](http://unix.stackexchange.com/questions/52814/flattening-a-nested-directory) – Ramesh Sep 11 '14 at 21:17
  • @user83873, I have voted to close it as duplicate of [this](http://unix.stackexchange.com/questions/52814/flattening-a-nested-directory) question. Check that question and I tried Gille's solution with zsh. I believe it is exactly what you are looking for. – Ramesh Sep 11 '14 at 21:18

1 Answers1

1

As long as all the files have different names you can do:

cd ~/foo/bar
find foo -type f -name "*.flac" -exec mv -t . {} \;

(you can leave out the -name "*.flac" part).

Anthon
  • 78,313
  • 42
  • 165
  • 222