0

I've tried Googling this but I only get answers relevant to Windows.

I've got a series of folders, for the sake of example I'll say ~/Downloads/abc ~/Downloads/def ~/Downloads/ghi etc.

What I would like to do, is empty the contents of each folder into a central folder, whether that be ~/Downloads, ~/Downloads/xyz, it doesn't particularly matter. However, I can't seem to figure out any way to practically do this.

Typing it out, I'm not sure if it makes sense, so I'll provide a visual example.

Downloads | Downloads
├abc      | ├abc
│└foo.txt > ├def
└def      | ├foo.txt
 └bar.txt | └bar.txt

Oh, and one more thing, I use Thunar for a file browser. I imagine this is at least doable directly from the terminal, but if there's a way to do it in Thunar as well, that would be just as good to know. Thanks!

Shawnsg
  • 11

1 Answers1

1

With zsh:

autoload zmv
cd ~/Downdload
zmv '*/(*)(#qD)' '$2'

You could also do mv -i -- */*(D) ., but using zmv has the advantage of erroring out in case of conflict (like when there's both a abc/file and def/file) before it starts moving files.

To remove empty dirs afterwards:

rmdir -- *(D/^F)