Let's say I have a
source/ directory which has many subdirectories. Some of these subdirectories have sub-subdirectories, and some of those sub-subdirectories have sub-sub-subdirectories, and so on.
What I want to do is recursively find all lowest-level subdirectories (subdirectories that do not have any further subdirectories) of
source/ and move them to a new target directory.
For instance, let's say the original
source/ looks like this:
/source/dir1 --Subdirectory without sub-subdirectory /source/dir2 --Subdirectory with sub-subdirectory /source/dir2/dir2.a --Sub-subdirectory without sub-sub-subdirectory /source/dir2/dir2.b --Sub-subdirectory without sub-sub-subdirectory
Then after the operation, the
target directory should look like this:
/target/dir1 /target/dir2.a /target/dir2.b
Is there a way to do this with a terminal command?