3

Is there any tool, which can compare 2 directories( with different sub dirs) for same named files?

Eg. DirA has subdir DirA1, DirA1 has one file named file.cpp.

DirB has file.cpp.

Dira->DirA1->file.cpp and DirB->file.cpp.

So, iF i compare these 2 dirs with BC, BC doesnt compare these 2 files. It'll mark them as orphans on both sides.

Can we write any BC script to compare these two files?

PS: I could have 10-100 files in both folders to compare. The point is how to make the comparison tool look for matching file names, irrespective of dir level.

I hope my question makes sense here.

JLRishe
  • 99,490
  • 19
  • 131
  • 169
Bolt
  • 33
  • 1
  • 3

2 Answers2

4

Beyond Compare 3 has an option in the View menu (Ignore Folder Structure) that does exactly what you want. It iterates over all of the subfolders for every file and displays them in a single level with files aligned based on names. If there happen to be multiple files with the same name it will give priority to aligning ones with the same directory structure.

Matthew Lock
  • 13,144
  • 12
  • 92
  • 130
Zoë Peterson
  • 13,094
  • 2
  • 44
  • 64
  • Thanks Craig... I had BC2, just installed BC3 and checked.It works as per requirement. Does Winmerge or any other Opensource package support this feature ? – Bolt Jan 18 '13 at 03:59
  • 1
    @Bolt BC3 is the only one I know of that supports it, but it's been a while since I seriously evaluated our competitors. I just ran through the open source ones that are available on Windows and none of them do. – Zoë Peterson Jan 18 '13 at 16:26
  • BC lets you download a fully functional trial version that lasts 30 days from memory http://www.scootersoftware.com/download.php – Matthew Lock Sep 29 '14 at 10:04
2

Short of writing scripts, here's quick and dirty way to achieve that:

  1. Create two temporary directories - FlatA and FlatB.
  2. Zip both original directories DirA and DirB into separate zip files - ArchiveA.zip and ArchiveB.zip
  3. Unzip both archives into FlatA and FlatB respectively, without paths.
  4. Use BeyondCompare to compare "flattened" folders FlatA and FlatB
Cozzamara
  • 1,318
  • 1
  • 14
  • 22
  • What if there is a file with same name in different sub folders? – NeonGlow Jan 17 '13 at 06:14
  • @NeonGlow He specifically wants to compare contents of files with identical names across two directories, regardless of their nesting level, so it sounds like identical names on one side are not a concern for this task - that's the whole point of this problem. In the solution I suggested, any extraction tool such as WinZip will prompt whether to overwrite, skip or possibly rename files with the same names (when relatives paths are dropped). – Cozzamara Jan 17 '13 at 06:28
  • I dont understand how archiving wud help .I guess my question wasn't clear. I want some tool who ll compare a particular file, irrespective of its parent dir name .Dira->DirA1->file.cpp and DirB->file.cpp. So if i compare DirA and DirB , file.cpp should not come as orphan in Dir B, the tool should try to compare file.cpp (of DirB) against file.cpp of DirA/DirA1 . Is it possible ? – Bolt Jan 17 '13 at 08:31
  • I understand your question. Archiving would help in that it's the simplest way to flatten directory on Windows (when you unzip) - i.e. dump all files from sub-directories into a single directory. At that point, you have two directories with just files - no sub-directories, and you can run BC on that. – Cozzamara Jan 17 '13 at 08:35
  • Yeah .. As u say it may work ,,, i am looking for some solution which can be used be in less time ,and repeatedly. Everytime, when i update my source code (cud be somewhere ~800MBs) , i can not do zip and unzipping. Flattening dir wud surely work. But is there any other way ? – Bolt Jan 17 '13 at 08:38
  • 1
    If archiving is not an option, I'd write some script (Perl, batch, Bash, etc), which finds matching files between two hierarchies and run each matching pair through `diff`, for example. It can then dump only file pairs having differences into two temp dirs for manual comparison by BC. – Cozzamara Jan 17 '13 at 08:45