请注意,这还将复制仅包含文件夹的文件夹,而不仅仅是包含至少一个文件的文件夹。不确定是否正是您要找的东西;无论如何,我会保留它,以免对其他人有用。
使用find
:
find source -mindepth 2 -maxdepth 2 -type d -not -empty -exec mv {} target \;
source
:搜索 source/
-mindepth 2
:从指定目录层次结构的第二级开始搜索-maxdepth 2
:搜索在指定目录层次结构的第二层停止-type d
:仅搜索目录-not
:否定以下条件/动作-empty
:仅搜索空文件夹-exec [...]
:对于每个结果,执行以下命令mv {} target \;
:将每个结果移到 target/
user@debian ~/tmp % tree
.
├── source
│ ├── folder A
│ │ └── folder A
│ │ ├── file1
│ │ ├── file2
│ │ └── file3
│ └── folder B
│ └── folder B
└── target
6 directories, 3 files
user@debian ~/tmp % find source -mindepth 2 -maxdepth 2 -type d -not -empty -exec mv {} target \;
user@debian ~/tmp % tree
.
├── source
│ ├── folder A
│ └── folder B
│ └── folder B
└── target
└── folder A
├── file1
├── file2
└── file3
6 directories, 3 files
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句