How to Compare Files in Two Directories

I have used hundreds of scripts in my time. In the past, modifying a script involved changing the core files directly. It was not a big problem modifying the core files, however it made upgrading the modified script a real pain. For example, upgrading vBulletin used to involve re-applying hacks to dozens of files after upgrading. It was very time-consuming and there was always room for things to go wrong.

Nowadays, most scripts use an extension system so that core files do you need to be modified. They also use a templating system so that website owners can modify their website design through their admin panel.

My private discussion forum Rise Forums uses Amember to handle memberships. It’s a great script, though in order to change templates, you need to modify the core files. This is obviously a problem during upgrades.

I launched the website using Amember 4.3.5. This week Amember released version 4.3.6. With scripts such as WordPress, all you have to do is upload the files. I could not do this as I had modified several templates. If I simply uploaded the new files, the changes would be lost.

Stupidly, I did not keep a record of the files I modified.

Thankfully, you can check what files have have been modified by using a file comparison program. I used the program TreeCompare. It’s an old script that is available free on Windows.

TreeCompare Script

The script is very easy to use. All you need to do is define the paths of your two directories. In my case, my first path was the folder containing the modified files that I am using on my website. The second path contained an unaltered version of Amember 4.35.

After defining your paths, you simply click the compare button.

Choose Your Paths

The results pop up shows how many directories and files were scanned. Importantly, the number of directories and files that are different is also displayed.

Compared Files

Dragging the path field over highlights exactly what files had been modified.

Modified Files

This shows me what files had been modified, but it does not show me what had been modified. A handy service for doing this is DiffNow. The service will show you the difference between any two files. You can do this via copy and paste, file upload or by entering the URL of the files.

DiffNow

DiffNow highlights the exact code that has been modified.

Compared Files

Using this procedure, I was able to see exactly what I added and removed from the core files. Future upgrades should go much smoother as after reviewing all changes, I decided to remove all of them except one essential modification. Therefore in the next upgrade, I only need to modify one file.

If you ever need to update a script that has been heavily modified, I recommend using the same technique. To recap, all you have to do is find the files that have been modified using TreeCompare and then compare those files directly using DiffNow.

Admittedly, TreeCompare is one of the most basic file comparison scripts available online. Other file comparison scripts you may want to check out are WinMerge, Beyond Compare, Meld and Compare++.

I hope you found this tutorial useful.

Good luck,
Kevin

I am an experienced blogger who has been working on the internet since 2000. On this blog, I talk about WordPress, internet marketing, YouTube, technology and travelling.
Share This