1

I'm looking for a command line tool to check if files are the same or not, I know there are "fc" and "comp" but I'm not sure which is better or if they are safe or not.

I have different files in different formats (txt, kdbx, keyx, png, rar) so I want a tool that can check all formats even KeePass database (kdbx). I'm also thinking about hash comparison (checksum), but I'm new to these things.

My goal is to use that command line before backing up to ssd, I want to avoid unnecessary writes by skipping similar files, because Robocopy/fastcopy/terracopy can't do that, they only check date and size and timestamp.

amymor
  • 75

2 Answers2

2

You can create hashes of files and compare them. Open powershell prompt and execute:

Get-fileHash file_name

and you will get output like:

Algorithm       Hash                                                                   Path
---------       ----                                                                   ----
SHA256          BD94760347BABBB0B12ADFEB41FF01B90DD7F4C16F9B6C2088CD2526F6223898       file_name

The big string BD9..... is the hash. SO if two files have the same hash they are the same (with very high probability)

Romeo Ninov
  • 7,848
0

Hash comparison is the most efficient and universal method for verifying file integrity across all formats (text, binary, images, and encrypted databases), as it generates a unique checksum for each file.

Generate Hashes: Use sha256sum (or sha1sum, md5sum) to compute file checksums:

sha256sum file1.txt file2.txt

Interactive Selection: Combine fzf with sha256sum for dynamic file comparison:

fzf --preview 'sha256sum {}'

Remote Backup with rclone: rclone supports checksum-based comparison for syncing local and remote directories:

rclone check /source_directory remote:/backup_directory --checksum

KeePass (kdbx) Files: Hash comparison works for encrypted files like .kdbx, as the checksum reflects the file’s content, including encryption.