Super User is a question and answer site for computer enthusiasts and power users. 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

Lets say we have two directories:

Directory A:

aaa.mov
bbb.mov
ccc.mov
ddd.mov
eee.mov

Directory B:

subdir1/aaa.mov
subdir1/bbb.mov
subdir2/subsubdir/ccc.mov

How could I transfer from A to B/newDir, all files which do not exist under any B's subdirectories (ddd.mov & eee.mov)?

share|improve this question
    
Judging from /, operating system is Linux or Mac OS X? – Olli Feb 27 '11 at 10:02
    
well..Mac OS X :) – nuc Feb 27 '11 at 10:04
up vote 3 down vote accepted

A simple shell script will achieve what you want...

#!/bin/sh

SRCDIR=dira
DSTDIR=dirb
SRCFILES=`find ${SRCDIR} -type f -exec basename '{}' \;`
mkdir -p ${DSTDIR}/NewDir

for FILE in ${SRCFILES}
do
        FOUND=`find ${DSTDIR} -name ${FILE} -type f`
        if [ -z ${FOUND} ]
        then
                echo -n "Copying ${FILE}..."
                cp ${SRCDIR}/${FILE} ${DSTDIR}/NewDir
                echo "done"
        fi
done
share|improve this answer
    
Thank you so much! It worked so great! :) – nuc Feb 27 '11 at 13:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .