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)?

link|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
feedback

1 Answer

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
link|improve this answer
Thank you so much! It worked so great! :) – nuc Feb 27 '11 at 13:09
feedback

Your Answer

 
or
required, but never shown

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