Suppose I have a bunch of zip files in several directories:
Fol1/Fol2
Fol3
Fol4/Fol5
And I want to move them all to a common base folder. How would I do this?
|
Suppose I have a bunch of zip files in several directories:
And I want to move them all to a common base folder. How would I do this? |
|||||
|
|
If you only want to move the
|
|||
|
|
|
Go to the toplevel directory of the tree containing the zip files (
This works out of the box in zsh. If your shell is bash, you'll need to run Alternatively, use
If you want to remove empty directories afterwards, in zsh:
In bash or ksh:
and repeat as long as there are empty directories to remove. Alternatively, in any shell
|
|||
|
|
|
If you're using bash version 4 or higher or zsh you can also use recursive globbing:
This will move ONLY the files and not their relative paths, so collisions might occur. |
|||
|
|
|
As a bash hack, you could use the power of
This has the advantage that it does not depend on file extensions, since it uses the The final Of course this is particularly suitable if the origin/ and target/ folders are on different disks. Otherwise the other solutions proposed are more efficient (even if they rely on naming conventions, instead of |
|||
|
|