Gamingforce Interactive Forums
Day 1 - 24 days until Christmas

Go Back   Gamingforce Interactive Forums > Gamingforce Computing > OS and Software
Register FAQ GFWiki Members List Donate Arcade ChocoJournal Mark Forums Read

Welcome to the Gamingforce Interactive Forums.
GFF is a community of gaming and music enthusiasts. We have a team of dedicated moderators, constant member-organized activities, and plenty of custom features, including our unique journal system. If this is your first visit, be sure to check out the FAQ or our GFWiki. You will have to register before you can post. Membership is completely free (and gets rid of the pesky advertisement unit underneath this message).


Directory Comparer?
Reply
 
LinkBack Thread Tools
Sensors indicate an Ancient Civilization


Member 1200

Level 26.92

Mar 2006


Reply With Quote
Old Aug 5, 2006, 02:14 AM #1 (permalink) of 9
Directory Comparer?

Does anyone know of a good tool to compare two directories and tell me the differences between them? I've got a couple of directories, each with about 3,000 pictures in them (convienienty named DSC_****.JPG) that are about 95% the same. I want something to quickly tell me what files are in one that aren't in the other. I could probably whip up a quick UNIX shell script, except that this is a Windows box. Google brought up the usual list of generic spyware that I don't particularly trust. Anyone know of anything that might do what I need?

Oh, and all I need it to compare is filenames. It doesn't need to, and in fact should NOT check if the files themselves are identical (which is part of why I can't use rsync).
Carob Nut


Member 2379

Level 4.50

Mar 2006


Reply With Quote
Old Aug 7, 2006, 06:42 PM #2 (permalink) of 9
I have used windiff in the past. It is part of windows support tools and you can download it at the following address

http://www.microsoft.com/downloads/d...DisplayLang=en
Sensors indicate an Ancient Civilization


Member 1200

Level 26.92

Mar 2006


Reply With Quote
Old Aug 7, 2006, 07:16 PM #3 (permalink) of 9
Cool. Thanks. I ended up just booting into Gentoo and writing a shell script after all. I gave in. That tool could have been useful, however.
Everything new is old again


Member 613

Level 29.52

Mar 2006


Reply With Quote
Old Aug 7, 2006, 08:22 PM Local time: Aug 7, 2006, 05:22 PM #4 (permalink) of 9
Originally Posted by NudeNinja
I have used windiff in the past. It is part of windows support tools and you can download it at the following address

http://www.microsoft.com/downloads/d...DisplayLang=en
Thanks for the link! Now I know that my copy of the WinXP Pro CD is better than the other downloaded versions (except that it's not bootable!).
When Smokers try to lasso him, he grabs their tongues and pulls them to HIM instead.

When Hunters jump on him he flips them over, pins them to the ground, and rips out their teeth one at a time.

When Boomers vomit on him he wipes himself off, shoots peptobismol into their mouths, and performs liposuction on them before splattering their brains on the wall.

When a Tank throws a chunk of concrete at him he rolls up his sleeves and puts on boxing gloves.

When a Witch gives him lip he pulls his hand back and slaps that bitch right in the mouth.

No zombie is safe from Chicago Ted.
Something


Member 29

Level 13.21

Mar 2006


Reply With Quote
Old Aug 7, 2006, 08:53 PM Local time: Aug 7, 2006, 04:53 PM #5 (permalink) of 9
Originally Posted by Arainach
Cool. Thanks. I ended up just booting into Gentoo and writing a shell script after all. I gave in. That tool could have been useful, however.
Might you post that here? I'm curious how you went about it, since I can't figure much of an idea for it, and this would be useful.

If you don't mind, of course.


Need help using an FTP client? Look no further! лл
Mountain Chocobo


Member 6745

Level 27.57

May 2006


Reply With Quote
Old Aug 8, 2006, 09:54 AM Local time: Aug 8, 2006, 02:54 PM #6 (permalink) of 9
You could have used CygWin for POSIX emulation. Great for having a unix environment on your windows system.
YA RLY


Member 8978

Level 7.21

Jun 2006


Reply With Quote
Old Aug 8, 2006, 10:20 AM #7 (permalink) of 9
Originally Posted by Duminas
Might you post that here? I'm curious how you went about it, since I can't figure much of an idea for it, and this would be useful.

If you don't mind, of course.
Can't you just use the "diff" command? For example, when I enter:

diff /home/tkang /home/tkang/J2Rev.0.2

I get

Only in /home/tkang: .bash_history
Only in /home/tkang: .bash_profile
...
Only in /home/tkang/J2Rev.0.2: Getstring.h
etc...

You can also use it to compare files as well.
Sensors indicate an Ancient Civilization


Member 1200

Level 26.92

Mar 2006


Reply With Quote
Old Aug 8, 2006, 10:47 AM #8 (permalink) of 9
Originally Posted by Duminas
Might you post that here? I'm curious how you went about it, since I can't figure much of an idea for it, and this would be useful.

If you don't mind, of course.
The version I wrote was just a simple thing which essentially mixed "for i in '(ls -A $1)']; do" with "if [-e $2/$i]". It didn't check for subdirectories, symbolic links, or any of the other obvious error checking that a truly useful script would since it was just a one-time thing.

However, a quick bit of Googling found cmptree, which is kind of what I wanted except on steroids.

Code:
#!/bin/bash
#
# cmptree: compare directory trees recursively and report the differences.
# Author: Ives Aerts

function gettype () {
  if [ -L $1 ]; then
    echo "softlink"
  elif [ -f $1 ]; then
    echo "file"
  elif [ -d $1 ]; then
    echo "directory"
  else
    echo "unknown"
  fi
}

function exists () {
  if [ -e $1 -o -L $1 ]; then
    return 0;
  else
    echo "$1 does not exist."
    return 1;
  fi
}

function comparefile () {
  cmp -s $1 $2
  if [ $? -gt 0 ]; then
    echo "$1 different from $2"
#  else
#    echo "$1 same as $2"
  fi
  return
}

function comparedirectory () {
  local result=0
  for i in `(ls -A $1 && ls -A $2) | sort | uniq`; do
    compare $1/$i $2/$i || result=1
  done
  return $result
}

function comparesoftlink () {
  local dest1=`ls -l $1 | awk '{ print $11 }'`
  local dest2=`ls -l $2 | awk '{ print $11 }'`

  if [ $dest1 = $dest2 ]; then
    return 0
  else
    echo "different link targets $1 -> $dest1, $2 -> $dest2"
    return 1
  fi
}

# compare a file, directory, or softlink
function compare () {
  (exists $1 && exists $2) || return 1;

  local type1=$(gettype $1)
  local type2=$(gettype $2)

  if [ $type1 = $type2 ]; then
    case $type1 in
      file)
        comparefile $1 $2
        ;;
      directory)
        comparedirectory $1 $2
        ;;
      softlink)
        comparesoftlink $1 $2
        ;;
      *)
        echo "$1 of unknown type"
        false
        ;;
    esac
  else
    echo "type mismatch: $type1 ($1) and $type2 ($2)."
    false
  fi

  return
}

if [ 2 -ne $# ]; then
cat << EOU
Usage: $0 dir1 dir2
Compare directory trees:
  files are binary compared (cmp)
  directories are checked for identical content
  soft links are checked for identical targets
EOU
  exit 10
fi

compare $1 $2
exit $?
Carob Nut


Member 2379

Level 4.50

Mar 2006


Reply With Quote
Old Aug 8, 2006, 06:57 PM #9 (permalink) of 9
here's a rough command that could be used in the console in windows to tell what files in the source folder are or aren't in the destination folder and dump whether or not they filecompare as the same file as well. I think it gets rather spammy though if files don't compare exactly.

it would be run from the source directory and tmp2 would need to be replaced with the target directory.

for %i in ( *.* ) do if exist "tmp2\%i" (fc %i tmp2\%i >> Filecompare.txt ) else echo
File tmp2\%i not found >> FileNOTFound.txt

ah the good old days before GUI's did all this crap.
Reply


Thread Tools

Gamingforce Interactive Forums > Gamingforce Computing > OS and Software > Directory Comparer?

Forum Jump



All times are GMT -5. The time now is 03:15 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0