How to Get Diff Between All Files Inside 2 Folders That Are on the Web

How to get diff between all files inside 2 folders that are on the web?

Once you have the source trees, e.g.

diff -ENwbur repos1/ repos2/ 

Even better

diff -ENwbur repos1/ repos2/  | kompare -o -

and have a crack at it in a good gui tool :)

  • -Ewb ignore the bulk of whitespace changes
  • -N detect new files
  • -u unified
  • -r recurse

Diff files present in two different directories

You can use the diff command for that:

diff -bur folder1/ folder2/

This will output a recursive diff that ignore spaces, with a unified context:

  • b flag means ignoring whitespace
  • u flag means a unified context (3 lines before and after)
  • r flag means recursive

Diffing between two entire directories/projects in hg or git?

git diff does exactly that. but it only works for git projects.

hg diff, svn diff pretty every version control system can diff directory trees

Comparing two folders for non identical files in CMD

You could use the comp command:
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/comp

comp C:\PathA\A C:\PathB\B > C:\Comparison\comparison-between-A-B.txt

compare files with same name in 2 folders and check their size to delete the bigger one in Python

Deleting files based on size

This is a simple procedure and can be implemented in one funciton.

def  compare_folders(path1, path2):
ignore = [".", "..", ".DS_Store"] # ignore these pointers/ files
for file in os.listdir(path1):
if file in os.listdir(path2):
if file not in ignore:
delete_larger_file(path1 + "/" + file, path2 + "/" + file)


def merge_folders(path1, path2):
for file in os.listdir(path1):
if file not in os.listdir(path2):
os.rename(path1 + "/" + file, path2 + "/" + file)

def delete_larger_file(path1, path2):
if os.path.getsize(path1) > os.path.getsize(path2):
os.remove(path1)
else:
os.remove(path2)

What's going on here?

  • The first function compare_folders() will take the paths to the folders being compared as inputs. It will then iterate through the contents of each folder and call the other function delete_larger_file() which compares the sizes of 2 files and deletes the larger one.
  • A subsequent call to merge_folders() is necessary to merge the folders in place. In other words, it will compare the contents of both folders and move the files that are not in one to the other. In the end, one folder should be empty and the other one should have all the smallest files.
  • Be warned: this cannot be undone so maybe test it first? Also if there are subfolders this will not work and will require recursion.

First call compare_folders() then call merge_folders

is there a compare folders feature in VS Code?

No.

As stated in https://github.com/microsoft/vscode/issues/98197, VS Code does not plan on adding this feature in the near term future.

Other options

https://marketplace.visualstudio.com/items?itemName=moshfeu.compare-folders claims to compare folders, but I can't speak to its effectiveness.

Usually I would just use diff -r or some type of git diff compare, as comparing a lot of files can sometimes not be a fun thing to do manually.

If both folders are git trees it becomes possible to compare them with git diff commands.



Related Topics



Leave a reply



Submit