将嵌套文件夹的内容递归复制到一个文件夹(终端) [英] Copy nested folders contents to one folder recursively (terminal)
本文介绍了将嵌套文件夹的内容递归复制到一个文件夹(终端)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个使用子文件夹构建几个月的Wordpress上传文件夹。
I have a Wordpress upload folder that is structured using subfolders for months.
wolfr2:uploads wolfr$ tree .
.
|-- 2007
| |-- 08
| | |-- beautifulkatamari.jpg
| | |-- beautifulkatamari.thumbnail.jpg
| | |-- beetle.jpg
| | |-- beetle.thumbnail.jpg
如何使用终端将所有图像递归复制到另一个图像中夹?我似乎无法像使用通配符文件名一样通配文件夹。 (例如* .jpg或*)(我在Mac OSX上)
How do I use terminal to copy all the images recursively into another folder? I can't seem to wildcard folders like you can wildcard filenames. (e.g. *.jpg or *) (I'm on Mac OSX)
cp -R ./*.jpg .
?
推荐答案
这会将所有* .jpg文件从当前文件夹复制到新文件夹并保留目录结构。
This will copy all *.jpg files from the current folder to a new folder and preserve the directory structure.
tar cvfp `find . -name "*.jpg"` | (cd <newfolder>; tar xfp -)
要复制而不保留目录结构:
To copy without preserving the directory structure:
cp `find . -name "*.jpg"` <newfolder>
这篇关于将嵌套文件夹的内容递归复制到一个文件夹(终端)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文