Reputation: 768
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
Upvotes: 0
Views: 794
Reputation: 1647
You can use rsync to copy one directory into another. If you need only some particular files, feel free to use --exclude
and --include
option.
rsync -avz --include='[iI]mage' --include='EPS' --exclude='*' source/ output/
To test command add rsync --dry-run option:
--dry-run perform a trial run with no changes made
You can find some examples of rsync include parameters in this thread.
Upvotes: 2
Reputation: 9058
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 | awk ....
That is -- just let find print them out and xargs file to run the file command.
Note that your sudo command will do the find but it's not going to sudo the entire line. That's going to cause you more trouble (if you need sudo at all).
Upvotes: 2