To compare the content of two folders by some app in OS X

3

2

I am improving my friend's LaTeX document at folder 1/2, while he is editing the folder 1/1.

The initial contents of the folders is the same.

How can you meld the two folders to one such that all files are melded?

Léo Léopold Hertz 준영

Posted 2009-07-30T15:06:13.773

Reputation: 4 828

Answers

9

You're wanting to find the differences in files in two folders and merge the changes?

If you're looking for a GUI utility you can use FileMerge which can be found at /Developer/Applications/Utilities/ if you have Apple's Developer Tools installed. It has some odd bugs - mostly to deal with handling file encoding.

If you're looking for something faster and nicer check out Changes.app - it's not cheap but has been worth the price of admission several times over for me.

If you want to do it via the command line you can use diff to find the differences and then manually merge the files together as it will list all the differences. (eg. diff ~/Desktop/a ~/Desktop/b)

Chealion

Posted 2009-07-30T15:06:13.773

Reputation: 22 932

2

Since the mac is running a version of unix, you can use all of the tried, tested and true commands from the established UNIX heritage.

UNIX Shell Comparison of Directories Tutorial

Axxmasterr

Posted 2009-07-30T15:06:13.773

Reputation: 7 584

2

The following code is made by Git-community

#!/bin/sh
#
# Filemerge.app must not already be open before running
# this script, or opendiff below will return immediately,
# and the TMPDIRs deleted before it gets the chance to read
# them.

[ \$# -eq 7 ] && opendiff "\$2" "\$5"
EOF
chmod +x merge.sh
GIT_EXTERNAL_DIFF=./merge.sh git-diff 


if test $# = 0; then
   OLD=`git-write-tree`
elif test "$1" = --cached; then
   OLD=HEAD
   NEW=`git-write-tree`
   shift
fi
if test $# -gt 0; then
   OLD="$1"; shift
fi
test $# -gt 0 && test -z "$CACHED" && NEW="$1"

TMPDIR1=`mktemp -d`
git-archive --format=tar $OLD | (cd $TMPDIR1; tar xf -)
if test -z "$NEW"; then
   TMPDIR2=$(git rev-parse --show-cdup)
   test -z "$cdup" && TMPDIR2=.
else
   TMPDIR2=`mktemp -d`
   git-archive --format=tar $NEW | (cd $TMPDIR2; tar xf -)
fi

opendiff $TMPDIR1 $TMPDIR2 | cat
rm -rf $TMPDIR1
test ! -z "$NEW" && rm -rf $TMPDIR2

You can then run

opendiff folder1 folder2

to achieve what I want.

Léo Léopold Hertz 준영

Posted 2009-07-30T15:06:13.773

Reputation: 4 828