I am trying to find files with specific extensions and copy or rsync it to another hard drive / directory
sudo find . \( -type f \( -iname '*.jpg' -o -iname "*png" -o -iname "*mov" -o -iname "*mp3" -o -iname "*mp4" -o -iname "*swf" -o -iname "*avi" \) -exec rsync {} ~/test/dest/ \; \)
and shell output is this:
cp: './dest/DSC_0085.JPG' and '/home/sanz/test/dest/DSC_0085.JPG' are the same file
cp: './dest/DSC_0086.avi' and '/home/sanz/test/dest/DSC_0086.avi' are the same file
and so on...
Why does it keep telling me that what I'm copying and where I'm trying to copy are the same file, even though they are in different directors. this makes no sense.
I'm also trying different command variant, but it also doesn't work as I wanted it to work:
sudo find . -type f -iname '*.jpg' -o -name "*png" -o -name "*mov" -o -name "*mp3" -o -name "*mp4" -o -name "*swf" -o -name "*avi" -exec rsync -ah --progress {} ~/test/dest \;
It copies ONLY avi files and completely ignores others. It is just strange to me how the same command without -exec normally outputs all the specifically labelled files, but when I want it to work with copying command it only reads/copies avi files.
cp
vs.rsync
)? The output is understandable if you ran the command withcp
in thetest
directory. Source and destination of the files are the same. Related: Is it possible to exclude a directory from the find command? – Freddy Apr 18 '20 at 21:04