1

I have a bunch of MP4 videos in a directory tree (by category), and I want to recursively copy them all to a single directory on another drive. I tried:

cp -R -p -f /hdd1mnt/Videos/*.mp4 /hdd2mnt/

But it just copies the few files in the /hddname/Videos/ directory and doesn't copy any of them from sub-directories under that. I've tried a few variations, but they all give the same result- no recursion. Please steer me right!

Thanks, Bill

lunix
  • 65
  • 10
  • 1
    Does this answer your question? [Recursively copy files from one directory to another](https://askubuntu.com/questions/802238/recursively-copy-files-from-one-directory-to-another) – Maythux Jan 17 '20 at 09:17

1 Answers1

0

Using The find Command

find: Search for files in a directory hierarchy

Generic:

find [sourcePath] -name ‘[filename]’ -exec cp {} [targetPath] \;

Your Example:

find /hdd1mnt/Videos/ -name '*.mp4' -exec cp {} /hdd2mnt/ \;

Replace -name with -iname to ignore case.

Broadsworde
  • 3,922
  • 4
  • 27
  • 45
  • THANK YOU! That does it perfectly. I'm going to put this in my web pages for future reference. – lunix Jan 17 '20 at 06:39