[英]Find and copy all images preserving the folder structure
I am trying to find and copy all the images from one location to another preserving the folder structure. 我正在尝试查找所有图像并将其从一个位置复制到另一个位置,以保留文件夹结构。 I have tried using the following command:
我尝试使用以下命令:
sudo find . -type f -exec file {} \; | awk -F: '{ if ($2 ~/[Ii]mage|EPS/) print $1}' | cpio -pdm /media/newlocation
This works fine for couple of minutes (I have gigabytes of files to be found and copies) but after some time I am getting the following error: 这在几分钟内可以正常工作(我有几千兆字节的文件要查找和复制),但是一段时间后,出现以下错误:
find: `file' terminated by signal 13
What is wrong with the command? 命令有什么问题? Is there better way of doing it?
有更好的方法吗?
Regards 问候
I'm not sure why you'd get sigpipe. 我不确定为什么会收到信号。
Rather than letting find do an exec, you could try: 您可以尝试:
find . 找 。 -type f -print |
型印刷 xargs file |
xargs文件| awk ....
啊...
That is -- just let find print them out and xargs file to run the file command. 也就是说-只需找到将它们打印出来并xargs文件即可运行file命令。
Note that your sudo command will do the find but it's not going to sudo the entire line. 请注意,您的sudo命令将执行查找,但不会对整个行进行sudo。 That's going to cause you more trouble (if you need sudo at all).
这将给您带来更多麻烦(如果您根本需要sudo)。
You can use rsync to copy one directory into another. 您可以使用rsync将一个目录复制到另一个目录。 If you need only some particular files, feel free to use
--exclude
and --include
option. 如果只需要某些特定文件,请随时使用
--exclude
和--include
选项。
rsync -avz --include='[iI]mage' --include='EPS' --exclude='*' source/ output/
To test command add rsync --dry-run option: 要测试命令,请添加rsync --dry-run选项:
--dry-run perform a trial run with no changes made
--dry-run执行试运行,不做任何更改
You can find some examples of rsync include parameters in this thread . 您可以在此线程中找到一些rsync include参数的示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.