Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Roughly, I have a folder setup like this on a linux server:


I want to eliminate the folders.... I want to copy the *.mkv files to the /show/ directory...

Can someone help me out with this one?

share|improve this question
up vote 3 down vote accepted

Alex's answer is fine. Here's a couple of alternate ways to do it too:

  1. find + xargs:

    find /show -name "*.mkv" -print0 | xargs -0 -Imkv cp mkv /show/

  2. find + parallel:

    find /show -name "*.mkv" -print0 | parallel -0 -j+0 cp {} /show/

the only interesting thing about using parallel instead of find/exec is that it can execute multiple commands in parallel. The -j+0 arguments will make it launch as many jobs at once as there are cpu cores. That might not be particularly useful if this operation is completemy disk-bound, but potentially it could speed up copying large numbers of files.

share|improve this answer
Are you missing a closing quote or is the one that's there extraneous? – Dennis Williamson Feb 4 '11 at 5:19

find /show -name "*.mkv" -exec cp {} /show/ \; will do the trick

share|improve this answer
I cant edit because its a 1 letter change, but always put the trailing / on directories. So ... cp {} /show/ .... If /show doesnt exist, the files will all clobber eachother on copy rather than generating errors – Patrick Feb 4 '11 at 3:01
"-exec mv" has more sense. – poige Feb 4 '11 at 3:02
You are right guys. Edited a command to add a trailing slash. Yep, mv has more sense, but the task was to copy files for some reason. – Alex Feb 4 '11 at 3:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.